从图像中获取良好的像素样本

发布于 2024-08-20 17:00:41 字数 247 浏览 9 评论 0原文

假设我有一张大图像,其中大约有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲欢浪云 2024-08-27 17:00:41

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文