Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ImageMagick标记连接的组件_Image_Image Processing_Imagemagick_Imagemagick Convert - Fatal编程技术网

使用ImageMagick标记连接的组件

使用ImageMagick标记连接的组件,image,image-processing,imagemagick,imagemagick-convert,Image,Image Processing,Imagemagick,Imagemagick Convert,是否可以使用ImageMagick在图像上执行连接组件标记 是的,现在可以使用ImageMagick 6.8.9-10及更新版本,请参阅 因此,如果我们从这张图片开始: 我们可以得到每个blob或component的标记组件以及边界框、质心和其他统计信息,如下所示: convert input.png \ -colorspace gray -negate -threshold 10% \ -

是否可以使用ImageMagick在图像上执行连接组件标记


是的,现在可以使用ImageMagick 6.8.9-10及更新版本,请参阅

因此,如果我们从这张图片开始:

我们可以得到每个
blob
component
的标记组件以及边界框、质心和其他统计信息,如下所示:

convert input.png                                    \
    -colorspace gray -negate -threshold 10%          \
    -define connected-components:verbose=true        \
    -define connected-components:area-threshold=100  \
    -connected-components 8 -auto-level output.png

Objects (id: bounding-box centroid area mean-color):
  0: 600x600+0+0 296.9,299.6 260033 srgb(0,0,0)
  2: 467x345+70+211 350.1,398.1 53563 srgb(255,255,255)
  1: 422x105+56+81 266.5,133.0 34814 srgb(255,255,255)
  4: 105x90+112+310 164.0,354.5 9450 srgb(255,255,255)
  3: 178x73+393+246 481.5,282.0 2140 srgb(255,255,255)
convert output.png -fill none -stroke red \
  -draw "rectangle 70,211 537,556"        \
  -draw "rectangle 56,81 478,186"         \
  -draw "rectangle 112,310 217,400"       \
  -draw "rectangle 393,246 571,319"       \
  x.png

然后可以按如下方式在边界框中绘制:

convert input.png                                    \
    -colorspace gray -negate -threshold 10%          \
    -define connected-components:verbose=true        \
    -define connected-components:area-threshold=100  \
    -connected-components 8 -auto-level output.png

Objects (id: bounding-box centroid area mean-color):
  0: 600x600+0+0 296.9,299.6 260033 srgb(0,0,0)
  2: 467x345+70+211 350.1,398.1 53563 srgb(255,255,255)
  1: 422x105+56+81 266.5,133.0 34814 srgb(255,255,255)
  4: 105x90+112+310 164.0,354.5 9450 srgb(255,255,255)
  3: 178x73+393+246 481.5,282.0 2140 srgb(255,255,255)
convert output.png -fill none -stroke red \
  -draw "rectangle 70,211 537,556"        \
  -draw "rectangle 56,81 478,186"         \
  -draw "rectangle 112,310 217,400"       \
  -draw "rectangle 393,246 571,319"       \
  x.png

如何将这些矩形裁剪成不同的文件?@Sigur如果你愿意,比如说。另一个文件中的第二个blob使用
convert input.png-crop 467x345+70+211 blob2.png
Perfect。现在我只需要如何从保存在外部文件中的信息自动执行此操作。我只需要剪切一些矩形,而不是全部。将其作为一个新问题,说明您的操作系统和外部文件的外观等,并复制到新问题的链接,粘贴到这里,我将在上午查看。问题和答案是免费的:-),或者您可以编写一个简单的
bash
脚本(除非您在Windows上)来提取裁剪几何体并对其进行修改。