imagemagickimagemagick-identify

Extract part of an image to identify


I try to get verbose information about a part of an image. I read the doc of imageMagick and as far as I understand it, it should be possible to call identify with the -extract option. But, when I call it, I got an error message: 'unrecognized option: -extract'.

This is my commandline call identify -verbose -extract 20x20+0+20 ./mosaicTemplate.jpg

Does anyone knows, what is wrong with my commandline Call or has an convenient workaround?

Thanks in advance! Simon


Solution

  • Create a test image like this:

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

    enter image description here

    Now check details of top left corner where image is pretty red:

    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
    

    Now check details of bottom left corner where it is more blue:

    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