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

Uploaded Python 3

File details

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

File metadata

  • Download URL: segrs-0.1.2.tar.gz
  • Upload date:
  • Size: 5.8 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.2.tar.gz
Algorithm Hash digest
SHA256 b4d0ad8a5fc3f0be02227422a24552b8d0109b3750c71516197d666d67e78ffe
MD5 643d3d625aad8239c39475b32e1efc58
BLAKE2b-256 6999ed0434892072c4cf7d75f322678d5daded1b8fe80dcebb663bd7baa1b060

See more details on using hashes here.

File details

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

File metadata

  • Download URL: segrs-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f8504676142662886fd52630a0b700b2b9c1f0584bef87c227b4114c9fe58ff7
MD5 813bcfaa2a0bf365d1a28bfdb14dab43
BLAKE2b-256 1b6c8c4a0d7c3de2a4c9d7511a33a2be9fd2fa61dd979e41c2e969b49c6b2422

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