Count regions that have similar color

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
kaliber
Posts: 5
Joined: 2015-11-13T01:29:10-07:00
Authentication code: 1151

Count regions that have similar color

Post by kaliber »

Hello, I want to be able to detect the white regions in an image.
Here is an example.

Image

Precondition:
- SVG or Raster image
- Only two colors (mainly): black and white
- The regions are well defined: there are no tiny regions (eg. 1x1px regions)

Image

Postcondition:
- the numer of blank regions (11)


Thanks in advantage
Last edited by kaliber on 2016-01-27T12:14:01-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Count regions that has similar color

Post by fmw42 »

-connected components is what you want. See http://magick.imagemagick.org/script/co ... onents.php
kaliber
Posts: 5
Joined: 2015-11-13T01:29:10-07:00
Authentication code: 1151

Re: Count regions that have similar color

Post by kaliber »

Thanks. Very useful :)
Post Reply