从图像中获取良好的像素样本
假设我有一张大图像,其中大约有 90% 绿色像素、9% 蓝色像素和 1% 棕色像素。我想从大约有 2000,000 像素的整个图像中获取仅 100 像素的样本。
我不希望样本包含与其在原始图像中的频率相关的像素,而是应该具有相同数量的绿色、蓝色和棕色像素。
我在每种颜色之后使用 -ish ,因为像素具有不同的值,如果我知道每个图像的颜色,这将很容易做到,每个图像都有不同的颜色组,所以我需要想出一个通用的方法来做到这一点不依赖于我指定图像的颜色。
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, Each 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
2 兆像素为 8MB(每像素 32 位)。
您可以将二维像素数组视为一维数字列表并对其进行排序。
然后从排序列表中取出每第 n 个像素。
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.