Page 1 of 1
Find darkest region in the image
Posted: 2013-12-09T06:36:32-07:00
by jpsmaster16
I own 249x99 pixels in an image.
I need to find the darkest region in the image. This region will have a maximum size of 60x30 pixels
I'm starting now with ImageMagick. Have an average experience in PHP.
Re: Find darkest region in the image
Posted: 2013-12-09T11:55:05-07:00
by fmw42
Perhaps you should post a link to your image (post to dropbox and put link here). Also explain further -- need the pixels be contiguous or can they be scattered about the image?
The simplest way for any distribution is to just -threshold 0 and see how many black pixels you have. If too few, increment the threshold until you get sufficient numbers of black pixels.
If you need a contiguous rectangle, then create a black image of size 60x30 (or whatever is you smallest rectangle that is acceptable). Then use
compare -metric rmse -subimage-search -dissimilarity-threshold 1 yourimage blackimage resultimages
The position resulting will be the rectangle with the value closest to black.