Sample Point not centered! (Fixed in SVN)
Posted: 2013-04-03T17:00:20-07:00
The -sample' operation takes one color from each 'rectangular' region of the image.
However the selected 'sample' is from the top-left corner of each region.
Example... Reference (for color values)
Sample a 10x10 gradient to 2x2 samples
As you can see it selected the top and left pixel of each 5x5 rectangular region in the gradient image
I would have expected it to have selected the middle pixel, or for rectangles sized an even number of pixels the middle-top-left pixel.
As it stands if I have a grid of images and I sample it so one pixel is taken from each sub-image in the grid, I would only get the top-left pixel of each sub-image, that is more often than not a 'border' pixel (such as from a montage)
The exact pixel to sample important when sampling images that 'pixelated'. For example if sampling a 'spot' image generated by the 'JqMagick' package you would only get a 'black' image, and not the 'pixelated color'.
However the selected 'sample' is from the top-left corner of each region.
Example... Reference (for color values)
Code: Select all
convert -size 1x10 gradient: txt:
# ImageMagick pixel enumeration: 1,10,65535,srgb
0,0: (65535,65535,65535) #FFFFFFFFFFFF white
0,1: (58253,58253,58253) #E38DE38DE38D srgb(88.8884%,88.8884%,88.8884%)
0,2: (50972,50972,50972) #C71CC71CC71C srgb(77.7783%,77.7783%,77.7783%)
0,3: (43690,43690,43690) #AAAAAAAAAAAA srgb(170,170,170)
0,4: (36408,36408,36408) #8E388E388E38 srgb(55.555%,55.555%,55.555%)
0,5: (29127,29127,29127) #71C771C771C7 srgb(44.445%,44.445%,44.445%)
0,6: (21845,21845,21845) #555555555555 srgb(85,85,85)
0,7: (14563,14563,14563) #38E338E338E3 srgb(22.2217%,22.2217%,22.2217%)
0,8: ( 7282, 7282, 7282) #1C721C721C72 srgb(11.1116%,11.1116%,11.1116%)
0,9: ( 0, 0, 0) #000000000000 black
Code: Select all
convert -size 10x10 gradient: -sample 2x2\! txt:
# ImageMagick pixel enumeration: 2,2,65535,srgb
0,0: (65535,65535,65535) #FFFFFFFFFFFF white
1,0: (65535,65535,65535) #FFFFFFFFFFFF white
0,1: (29127,29127,29127) #71C771C771C7 srgb(44.445%,44.445%,44.445%)
1,1: (29127,29127,29127) #71C771C771C7 srgb(44.445%,44.445%,44.445%)
I would have expected it to have selected the middle pixel, or for rectangles sized an even number of pixels the middle-top-left pixel.
As it stands if I have a grid of images and I sample it so one pixel is taken from each sub-image in the grid, I would only get the top-left pixel of each sub-image, that is more often than not a 'border' pixel (such as from a montage)
The exact pixel to sample important when sampling images that 'pixelated'. For example if sampling a 'spot' image generated by the 'JqMagick' package you would only get a 'black' image, and not the 'pixelated color'.