Hi,
Say I have a 3000x3000 image. I want to programatically find which 600x600 square has the most detail in it. By detail, I mean lots of edges.
I basically want to show my users a close up section of an image to show them the quality of it, but without showing them the whole image in close up form. The small section of the image is only able to show quality if it has some fine detail in it (a 600x600 square of all the same color wouldn't work, but seeing lots of edges up close would).
Is there a way to get a numerical representation for how detailed an image is? I could do that over all of the sections and compare the values, maybe?
Thanks for your help. I don't know if I've explained this very well, so please ask me to clarify if anything doesn't make sense.
Find section of image with the most detail
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Find section of image with the most detail
Do you want to shift the 600x600 window one pixel at a time or by 600 pixels?
If the former, then you can either use -statistic to get the standard deviation or you can convert the image to edges (-edge) and then do -statistic to get the mean(average). Then use
identify -define identify:locate=maximum -define identify:limit=2 statisticimage.png
to find the largest one. Then get the coordinates and draw a square on the image corresponding to those coordinates as the center of the square.
If the latter, then resize the image such that each resized pixel corresponds to 600x600 block in the original image. Do the same as above. But compute the corresponding point in the original image before drawing the square. For drawing see -draw.
See
http://www.imagemagick.org/script/comma ... ptions.php
http://www.imagemagick.org/script/comma ... #statistic
http://www.imagemagick.org/script/comma ... s.php#edge
http://www.imagemagick.org/Usage/draw/
http://www.imagemagick.org/script/comma ... php#resize
http://www.imagemagick.org/Usage/resize/
http://www.imagemagick.org/script/identify.php
If the former, then you can either use -statistic to get the standard deviation or you can convert the image to edges (-edge) and then do -statistic to get the mean(average). Then use
identify -define identify:locate=maximum -define identify:limit=2 statisticimage.png
to find the largest one. Then get the coordinates and draw a square on the image corresponding to those coordinates as the center of the square.
If the latter, then resize the image such that each resized pixel corresponds to 600x600 block in the original image. Do the same as above. But compute the corresponding point in the original image before drawing the square. For drawing see -draw.
See
http://www.imagemagick.org/script/comma ... ptions.php
http://www.imagemagick.org/script/comma ... #statistic
http://www.imagemagick.org/script/comma ... s.php#edge
http://www.imagemagick.org/Usage/draw/
http://www.imagemagick.org/script/comma ... php#resize
http://www.imagemagick.org/Usage/resize/
http://www.imagemagick.org/script/identify.php
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Find section of image with the most detail
As Fred says.
My "Details, details" page shows a number of measures for detail, where "detail" is measured within a small window (eg 10x10). Your required window is larger (600x600), so you can either increase the size of the detail window, or blur the result (for a sliding 600x600 window) or scale it (for 600x600 blocks).
My "Details, details" page shows a number of measures for detail, where "detail" is measured within a small window (eg 10x10). Your required window is larger (600x600), so you can either increase the size of the detail window, or blur the result (for a sliding 600x600 window) or scale it (for 600x600 blocks).
snibgo's IM pages: im.snibgo.com
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Find section of image with the most detail
I'll mention another issue concerning this.davich wrote:By detail, I mean lots of edges.
We can get a value for each pixel that shows how much detail is there, and this gives us a value for every 600x600 square.
However, we might care about the entirety of each edge. For example, one candidate window might contain a single edge containing 300 pixels, while another window has two edges each containing only 100 pixels. Which window contain the "most detail"? Perhaps you want to count the edges themselves, rather than the count of pixels within edges.
Another example: if your display program automatically zooms in to the greatest detail, you might want to ensure that an edge structure isn't clipped by the border of the display window.
This problem, of integrating pixels into edge structures, isn't trivial. One complication is that binary edge detectors often create "broken" edges. (See my "Mending broken lines" page.)
snibgo's IM pages: im.snibgo.com
Re: Find section of image with the most detail
Hi, thanks for your replies.
Fred, I'm having some trouble with the identify command. Here's what I'm getting:
$ identify -define identify:locate=maximum -define identify:limit=2 testimage3.png
testimage3.png PNG 1000x1000 1000x1000+0+0 8-bit PseudoClass 256c 64.3KB 0.000u 0:00.000
identify: IDAT: duplicate sRGB information ignored `testimage3.png' @ warning/png.c/MagickPNGWarningHandler/1754.
identify: IDAT: duplicate `testimage3.png' @ warning/png.c/MagickPNGWarningHandler/1754.
identify: IDAT: invalid chromaticities `testimage3.png' @ warning/png.c/MagickPNGWarningHandler/1754.
How do I get from this output to the coordinates of a square?
Thanks
Fred, I'm having some trouble with the identify command. Here's what I'm getting:
$ identify -define identify:locate=maximum -define identify:limit=2 testimage3.png
testimage3.png PNG 1000x1000 1000x1000+0+0 8-bit PseudoClass 256c 64.3KB 0.000u 0:00.000
identify: IDAT: duplicate sRGB information ignored `testimage3.png' @ warning/png.c/MagickPNGWarningHandler/1754.
identify: IDAT: duplicate `testimage3.png' @ warning/png.c/MagickPNGWarningHandler/1754.
identify: IDAT: invalid chromaticities `testimage3.png' @ warning/png.c/MagickPNGWarningHandler/1754.
How do I get from this output to the coordinates of a square?
Thanks
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Find section of image with the most detail
What is your IM version and platform? What is testimage3.png and how did you create it?
Re: Find section of image with the most detail
I might be on an old version:
Version: ImageMagick 6.7.5-7 2014-09-30 Q8 http://www.imagemagick.org
on a Macbook Pro.
The image is a mean (average) image (of an edges image) created as per your instructions above. Here it is: http://imgur.com/Me4GkQq
$ convert testimage.png -edge 5 testimage2.png
$ convert testimage2.png -statistic Mean 20x20 testimage3.png
Thanks again for all your help!
Version: ImageMagick 6.7.5-7 2014-09-30 Q8 http://www.imagemagick.org
on a Macbook Pro.
The image is a mean (average) image (of an edges image) created as per your instructions above. Here it is: http://imgur.com/Me4GkQq
$ convert testimage.png -edge 5 testimage2.png
$ convert testimage2.png -statistic Mean 20x20 testimage3.png
Thanks again for all your help!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Find section of image with the most detail
That version is way too old to use identify to get your max location. That version is over 200 versions old. You should really upgrade.
You need at least
2013-08-29 6.8.6-10 Cristy <quetzlzacatenango@image...>
New identify define to output the location of the minimum, maximum, or mean pixel of the image (e.g. identify -define identify:locate=maximum -define identify:limit=7 rose).
But I have a slower prototype as a script that might work. See my script, maxima, at my link below.
You need at least
2013-08-29 6.8.6-10 Cristy <quetzlzacatenango@image...>
New identify define to output the location of the minimum, maximum, or mean pixel of the image (e.g. identify -define identify:locate=maximum -define identify:limit=7 rose).
But I have a slower prototype as a script that might work. See my script, maxima, at my link below.
Re: Find section of image with the most detail
Hi Fred! Sorry for the late follow up, but just wanted to say a huge THANK YOU! It's all working beautifully!
Thanks for your help
Thanks for your help
