提取图像的一部分以进行识别

时间:2015-11-06 09:45:40

标签: imagemagick imagemagick-identify

我尝试获取有关图像某一部分的详细信息。我阅读了imageMagick的文档,据我所知,应该可以使用-extract选项调用identify。但是,当我调用它时,我收到一条错误消息: 'unrecognized option: -extract'

这是我的命令行调用identify -verbose -extract 20x20+0+20 ./mosaicTemplate.jpg

有谁知道,我的命令行调用有什么问题或者有一个方便的解决方法?

提前致谢! 西蒙

1 个答案:

答案 0 :(得分:2)

像这样创建一个测试图像:

convert -size 500x500 gradient:red-blue image.png

enter image description here

现在查看左上角图像非常红的详细信息:

convert image.png -crop 20x20+0+0 -verbose info:

Image: image.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 20x20+0+0
  Units: Undefined
  Type: Palette
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 16-bit
  Channel depth:
    red: 16-bit
    green: 1-bit
    blue: 16-bit
  Channel statistics:
    Pixels: 400
    Red:
      min: 63040 (0.961929)
      max: 65535 (1)
      mean: 64287.3 (0.980962)                    <--- very red
      standard deviation: 757.295 (0.0115556)
      kurtosis: -1.20609
      skewness: 0.000125086
      entropy: 1
    Green:
      min: 0 (0)
      max: 0 (0)
      mean: 0 (0)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
      entropy: nan
    Blue:
      min: 0 (0)
      max: 2495 (0.0380713)
      mean: 1247.65 (0.0190379)              <--- not very blue
      standard deviation: 757.295 (0.0115556)
      kurtosis: -1.20609
      skewness: -0.000125086
      entropy: 1

现在查看左下角更详细的细节:

convert image.png -crop 20x20+0+480 -verbose info:

Image: image.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 20x20+0+0
  Units: Undefined
  Type: Palette
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 16-bit
  Channel depth:
    red: 16-bit
    green: 1-bit
    blue: 16-bit
  Channel statistics:
    Pixels: 400
    Red:
      min: 0 (0)
      max: 2495 (0.0380713)
      mean: 1247.65 (0.0190379)                  <--- not very red
      standard deviation: 757.295 (0.0115556)
      kurtosis: -1.20609
      skewness: -0.000125086
      entropy: 1
    Green:
      min: 0 (0)
      max: 0 (0)
      mean: 0 (0)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
      entropy: nan
    Blue:
      min: 63040 (0.961929)
      max: 65535 (1)
      mean: 64287.3 (0.980962)                     <--- very blue
      standard deviation: 757.295 (0.0115556)
      kurtosis: -1.20609
      skewness: 0.000125086
      entropy: 1