按颜色权重选择图像部分上的点

发布于 2024-10-03 07:30:50 字数 699 浏览 5 评论 0原文

需要在图像上(实际上是该图像的一部分)选择指定数量的点。图像的较暗部分更为重要。

最简单的方法是随机选择它们。但即使丢弃使用过的点,通常也会导致某些点距离其他点太近,尤其是在考虑重量时。

也许选择点后权重应该动态减少?没试过。

我注意到原始图像有太多不同的颜色,所以我想平滑它以剪掉相似的颜色。然而转换为灰度还不够。
我使用 Emgu CV (OpenCV 包装器)函数对图像进行二值化。我试图计算分水岭,但计算出的区域并不那么容易分开。一般来说,分水岭是检测较暗地方的“非直观”方法。

简单地说:我想从较暗的部分开始在图像上标记点 - 该部分应该比较亮的部分更频繁地标记。点应该分散在相似的颜色组上,以避免堆积在附近的地方。

该算法不必是准确的。它可以在下一次迭代中给出不同的结果。点数不会很大,从10到150-200。

如何计算从较暗区域开始散布在图像上的指定数量的点?

为了形象化我的意思,请看下图。它包含选定的点(数量~20)。大多选择较暗的部分。下一次迭代后,这些点不必出现在相同位置。但我想要的是在较亮区域的数量较多时选择点。

当然,对于不同的图像,跳出黑暗所需的点数会有所不同。

点选择后的图片

There is a need for selecting specified number of points on the image (actually on the part of that image). Darker parts of the image are more important.

The easiest way of doing this is by selecting them randomly. But even dropping used points usually finished with some points being located too close to others especially when respecting weights.

Maybe after selecting the point the weight should be decreased dynamically? Haven't tried.

I've noticed that original image has too many different colors so I wanted to smooth it to cut off similar colors. However converting to grayscale was not enough.
I used Emgu CV (OpenCV wrapper) functions to binarize image. Than I tried to calculate watershed but calculated areas are not so easy to separate. Generally watershed is pretty 'non-intuitive' approach to detect darker places.

Simply: I would like to mark points on the image starting from darker parts - that parts should be marked more frequently than lighter. Points should be scattered over group of colors that are similar to avoid being piled-up in nearby places.

The algorithm doesn't have to be accurate. It can give different results in next iterations. Number of points would not be very big from 10 to 150-200.

How to calculate specified number of points scattered on the image starting from the darker regions?

To visualize what I mean see the picture below. It contains selected points (qty. ~20). Mostly darker parts are selected. The points don't have to appear on the same locations after next iteration. But what I want is to select points on lighter regions when number of them would be higher.

Of course for different images the numbers of points needed to jump out of darkness would differ.

Picture after points selection

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

沐歌 2024-10-10 07:30:50

如果我正确理解你的问题,你需要图像上的点列表。该列表必须包含来自黑色区域的几个点和来自白色区域的几个点。

一个简单的方法 - 迭代每个像素。将当前像素的值存储在变量's'中,然后:

if(s < 64) // Darker
    if(rand() % 5 == 1)
        // Add to list
else      // White
    if(rand() % 25 == 1)
        // Add to list

If I understand your question correctly, you need a list of points on an image. The list must contain several points from the black regions and a few points from the white regions.

A simple approach - Iterate through each pixel. Store the value of the current pixel in a variable 's', then:

if(s < 64) // Darker
    if(rand() % 5 == 1)
        // Add to list
else      // White
    if(rand() % 25 == 1)
        // Add to list
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文