getting a good sample of pixels from an image
lets say I have a big image with about 90% greenish pixels, 9% bluish pixels and 1% brownish pixels. I want to get a sample of only 100 pixels from the whole image having around maybe 2000,000 pixels.
I don't want the sample to contain pixels relative to their frequency in the original image, rather it should have equal number of greenish, bluish and brownish pixels.
I use -ish after every color because the pixels have different values and also this would be easy to do if I knew the colors of each image, Eac开发者_开发问答h image has different color groups so I need to come up with a general way of doing this which does not depend on me specifying the colors of the image.
2 megapixel is 8MB at 32-bits per pixel.
You could treat the 2D array of pixels as a 1D list of numbers and sort it.
Then take every n'th pixel from the sorted list.
精彩评论