Hello,
I think I understand how histogram works. It returns the color values of an image (e.g. RGB) and the amount of pixels of the same color value in the whole image. So far so good. Is there a way one could look up e.g. a 3x3 pixels area of the SAME color value and return only information of colors that at least are identical within such a 3x3 pixels area? This is to look for "flatness" of colors in an image.
Example attached:
This is a 9x9 pixel image. With the above approach using 3x3 pixel area the result would return 14x 255,0,0  0x 255,255,255  14x 0,255,0
If one would use 4x4 pixel area analysis the result would return 6x 255,0,0  0x 255,255,255  6x 0,255,0
https://www.dropbox.com/s/18xdtqv65xixm ... 1.png?dl=0
Return histogram of image with pixel area 3x3 (4x4, 5x5, etc.)

 Posts: 12579
 Joined: 20100123T23:01:3307:00
 Authentication code: 1151
 Location: England, UK
Re: Return histogram of image with pixel area 3x3 (4x4, 5x5, etc.)
I'm not sure what you want.
In a 9x9 pixel image, there are nine 3x3 subimages that don't overlap, or fortynine 3x3 subimages that do overlap.
However, in the red area, there are fourteen 3x3 subimages 3x3 subimages that do overlap. Is that what you mean?
A 3x3 subimage that is all one colour has a standard deviation of zero. The operation "statistic standarddeviation 3x3" finds the SD for 3x3 subimages centred on all input pixels. You don't want the edge cases, so "shave 1x1" will remove these, to give just the fortynine cases.
In a 9x9 pixel image, there are nine 3x3 subimages that don't overlap, or fortynine 3x3 subimages that do overlap.
However, in the red area, there are fourteen 3x3 subimages 3x3 subimages that do overlap. Is that what you mean?
A 3x3 subimage that is all one colour has a standard deviation of zero. The operation "statistic standarddeviation 3x3" finds the SD for 3x3 subimages centred on all input pixels. You don't want the edge cases, so "shave 1x1" will remove these, to give just the fortynine cases.
snibgo's IM pages: im.snibgo.com

 Posts: 12579
 Joined: 20100123T23:01:3307:00
 Authentication code: 1151
 Location: England, UK
Re: Return histogram of image with pixel area 3x3 (4x4, 5x5, etc.)
Another method: "scale" the image down, then back up. Pixels that have changed were not at the centre of solidcolour regions. Pixels that remain the same were at the centre of solidcolour regions.
Related techniques can be used, eg windowed means.
Related techniques can be used, eg windowed means.
snibgo's IM pages: im.snibgo.com
Re: Return histogram of image with pixel area 3x3 (4x4, 5x5, etc.)
Hello,
thanks for your answers. I have tried statistic with standarddeviation (or better: RMS). Unfortunately with larger files (I tried one with 5000x5000px) the computation is extremely slow and the output text file is understandably extremely large  I got 1.3GB text file which will be impossible to process afterwards. What options do I have to directly create a "new" histogram with this information instead?
PS: this is the command that I used
PPS: the scale approach is too destructive or too prone to rounding factors for the purpose I have in mind. I might miss valuable information that I can't recover anymore
thanks for your answers. I have tried statistic with standarddeviation (or better: RMS). Unfortunately with larger files (I tried one with 5000x5000px) the computation is extremely slow and the output text file is understandably extremely large  I got 1.3GB text file which will be impossible to process afterwards. What options do I have to directly create a "new" histogram with this information instead?
PS: this is the command that I used
Code: Select all
magick verbose 3x3.tif shave 1x1 statistic RMS 3x3 3x3_out.txt

 Posts: 12579
 Joined: 20100123T23:01:3307:00
 Authentication code: 1151
 Location: England, UK
Re: Return histogram of image with pixel area 3x3 (4x4, 5x5, etc.)
I don't see how RMS helps.
The initial processing can be made massively faster using Integral images. I wouldn't process "txt:" of large images, as there is so much data and processing would take so long.
Can you link to a sample input file?
The initial processing can be made massively faster using Integral images. I wouldn't process "txt:" of large images, as there is so much data and processing would take so long.
Can you link to a sample input file?
snibgo's IM pages: im.snibgo.com
Re: Return histogram of image with pixel area 3x3 (4x4, 5x5, etc.)
Hello,
I've used RMS to return the color values directly (not the deviation value which is 0,0,0 for zero deviation). The idea is to get information of a "new" histogram which prefers pixels of same colors within a certain neighborhood area (e.g. 3x3, 4x4, 5x5, etc.). In that sense the "new" histogram information would show a better statistic of colors that are really flat in a picture rather than just a "dumb" pixel count without association of location itself.
Of course, if there's a better approach, I'd be very happy to learn.
Here the link to one of the files:
https://www.dropbox.com/s/tcly5oyijlxns ... s.jpg?dl=0
So the "new" histogram would show many pixels using, especially the larger we'd go with the pixel area (e.g. 5x5 or even 10x10):
239,240,224
127,167,158
153,130,60
171,157,182
182,155,66
211,160,81
61,49,0
152,126,109
181,45,67
I've used RMS to return the color values directly (not the deviation value which is 0,0,0 for zero deviation). The idea is to get information of a "new" histogram which prefers pixels of same colors within a certain neighborhood area (e.g. 3x3, 4x4, 5x5, etc.). In that sense the "new" histogram information would show a better statistic of colors that are really flat in a picture rather than just a "dumb" pixel count without association of location itself.
Of course, if there's a better approach, I'd be very happy to learn.
Here the link to one of the files:
https://www.dropbox.com/s/tcly5oyijlxns ... s.jpg?dl=0
So the "new" histogram would show many pixels using, especially the larger we'd go with the pixel area (e.g. 5x5 or even 10x10):
239,240,224
127,167,158
153,130,60
171,157,182
182,155,66
211,160,81
61,49,0
152,126,109
181,45,67