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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: segrs-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9634fc8b8e03a8fe1fee55290faa299605aa3993a86eb865ecc46bf83cacfd60
MD5 4699f2c707fe014c1854b7b63c9b0921
BLAKE2b-256 e328cde920bb9432f3945b5b5a7368f2041817ce1e8a938f6a97d42f7feba81a

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