基于水平线的切片图像

问题描述 投票:0回答:1

希望有人可以帮助我,或者只是确认这是否确实可行。

我有一个带有水平线的PNG文件。我想根据这些行将图像分成较小的文件。我该如何实现?使用imageMagick可以吗?或从任何其他应用程序对此可以实现自动处理和批量处理。

我还要附加文件,以便更清晰。

谢谢

原始文件:enter image description here

切片1:enter image description here

切片2:enter image description here

切片第3部分:enter image description here

切片第4部分:enter image description here

image-processing imagemagick image-manipulation imagemagick-convert
1个回答
1
投票

Bash脚本:

#!/bin/sh
w=$(identify -ping -format '%[width]' green_lines.png)
h=$(identify -ping -format '%[height]' green_lines.png)
convert green_lines.png -resize 1x"${h}"\! -resize "${w}"x"${h}"\! out_green.png
convert out_green.png -colorspace HSV -channel S -separate  out_greenS.png
convert out_greenS.png -threshold 50% -negate out_greenS.png

convert out_greenS.png -define connected-components:verbose=true \
-define connected-components:area-threshold=500000 \
-connected-components 8 objects.png| awk '{print $2}'|tail -n +2 >coodr.txt
i=0
while read size
do 
convert green_lines.png -crop "${size}"  crop_"${i}".png
i=$((i+1))
done < coodr.txt
© www.soinside.com 2019 - 2024. All rights reserved.