Skip to main content

Remote Sensing Image Segmentation Tools

Project description

segrs

遥感(RS)图像分割与合并工具,支持大图像的切片和切片的合并操作。

pip install segrs

更新情况:

  • 0.1.3fix bug

  • 0.1.0 初始化

核心功能

1. crop_tif - 图像切片

将大尺寸遥感图像切割为指定大小的小图块,支持重叠区域和命名规则。

参数说明

| 参数名 | 类型 | 默认值 | 说明 |

| -------------- | --------- | ------------ | ----------------------------------------------------------- |

| input_path | str | - | 输入的原始遥感图像路径(支持 .tif 格式) |

| output_dir | str | "output" | 切片保存的输出目录 |

| tile_size | int | 512 | 每个切片的宽高(单位:像素) |

| overlap | float | 0 | 切片之间的重叠比例(如 0.1 表示 10% 重叠) |

| keep_size | bool | False | 是否仅保留与 tile_size 完全匹配的切片(边缘不足时跳过) |

| name | str | "tile" | 切片文件名前缀(文件名格式:{name}_{列}_{行}.tif) |

使用示例

python
from segrs.RSsplit import crop_tif # 将 input.tif 切割为 512x512 像素的小图,重叠 10%,输出到 output_dir 目录 crop_tif( input_path="input.tif", output_dir="output_dir", tile_size=512, overlap=0.1, keep_size=True, name="rs_slice" )

2. merge_tiles - 图像合并

将切割后的切片重新合并为原始大图像。

参数说明

| 参数名 | 类型 | 默认值 | 说明 |

| --------------- | --------- | ---------- | --------------------------------------------------------------- |

| input_dir | str | - | 包含切片文件的目录(文件名需包含行列编号,如 tile_1_2.tif) |

| output_path | str | - | 合并后的输出文件路径 |

| tile_size | int | 512 | 切片的原始尺寸(需与切割时一致) |

| overlap | float | 0 | 切片的重叠比例(需与切割时一致) |

| name | str | "tile" | 切片文件名前缀(需与切割时一致) |

使用示例

python
from segrs.RSmerge import merge_tiles # 合并 input_dir 目录下的切片文件,生成 merged.tif merge_tiles( input_dir="input_dir", output_path="merged.tif", tile_size=512, overlap=0.1, name="rs_slice" )

依赖项

确保安装以下依赖:

bash
pip install rasterio numpy tqdm

注意事项

  1. 输入图像需为 .tif 格式(通过 rasterio 库支持)

  2. 切片文件名需严格遵循 name_{col}_{row}.tif 格式(如 tile_3_5.tif

  3. 合并时需保证 tile_sizeoverlap 参数与切割时一致

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

segrs-0.1.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

segrs-0.1.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file segrs-0.1.3.tar.gz.

File metadata

  • Download URL: segrs-0.1.3.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.15

File hashes

Hashes for segrs-0.1.3.tar.gz
Algorithm Hash digest
SHA256 78a359cce50ec79cee3bf8b93460283c9ccb53aed3231d59831ec35eaa0cfc99
MD5 b0d3b937a031e85c429198cf473c2b69
BLAKE2b-256 1cb6ef3522e278c4e236fb3a411822cc0e7035a6be45f334368659be921416d5

See more details on using hashes here.

File details

Details for the file segrs-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: segrs-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.15

File hashes

Hashes for segrs-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c347ef056207b80068dd9d7a51788f2f5aeeb818a166c0d52cd6199b6ad29120
MD5 6815b87c6bdc8433ceb5e165be3b3ba8
BLAKE2b-256 e8dec8a59e6f2d89b0875f4f3ac05df5393d88c2d6eaad438f62f43a96cd4c1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page