Skip to main content

Remote Sensing Image Segmentation Tools

Project description

segrs

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

pip install segrs

更新情况:

  • 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.0.tar.gz (5.1 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.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: segrs-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 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.0.tar.gz
Algorithm Hash digest
SHA256 57ccb0bad3a1ce6418865fe36e75b2f7d6af77000dd94821ed2b726c188b9043
MD5 4b020733c8e7aef8aa5695ab08f941df
BLAKE2b-256 06f2878c77ce4508bb00e1cf7d284d5c4aa8f91f7f4a878158c4fe78a70c58c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: segrs-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f3352a945adeb1e848c34c1d6107651149ca057c4efdac4e19bd102db0e1452
MD5 d67d59ad579b17065ea663e768dcfd00
BLAKE2b-256 1f83f6c30968e372ede2d798940fc0140723bd571a089b3b77d6f3dbac952095

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