How do I segment a 2D image into blobs of similar values efficiently? The given input is a n array of integer, which includes hue for non-gray pixels and brightness of gray pixels.
如何有效地将2D图像分割成具有相似值的blob?给定输入是n个整数数组,其中包括非灰色像素的色调和灰色像素的亮度。
I am writing a virtual mobile robot using Java, and I am using segmentation to analyze the map and also the image from the camera. This is a well-known problem in Computer Vision, but when it's on a robot performance does matter so I wanted some inputs. Algorithm is what matters, so you can post code in any language.
我正在使用Java编写虚拟移动机器人,我正在使用分段来分析地图以及来自摄像机的图像。这是计算机视觉中一个众所周知的问题,但是当它在机器人上时性能确实很重要,所以我想要一些输入。算法很重要,因此您可以使用任何语言发布代码。
- Wikipedia article: Segmentation (image processing)
- [PPT] Stanford CS-223-B Lecture 11 Segmentation and Grouping (which says Mean Shift is perhaps the best technique to date)
- Mean Shift Pictures (paper is also available from Dorin Comaniciu)
*文章:分割(图像处理)
[PPT] Stanford CS-223-B讲座11分段和分组(称Mean Shift可能是迄今为止最好的技术)
Mean Shift Pictures(纸张也可从Dorin Comaniciu获得)
5 个解决方案
#1
3
I would downsample,in colourspace and in number of pixels, use a vision method(probably meanshift) and upscale the result.
我会在colourspace和像素数量下采样,使用视觉方法(可能是meanshift)并升级结果。
This is good because downsampling also increases the robustness to noise, and makes it more likely that you get meaningful segments.
这很好,因为下采样也会增加对噪声的鲁棒性,并使您更有可能获得有意义的段。
You could use floodfill to smooth edges afterwards if you need smoothness.
如果需要平滑度,可以使用填充物来平滑边缘。
Some more thoughts (in response to your comment).
更多的想法(回应你的评论)。
1) Did you blend as you downsampled? y[i]=(x[2i]+x[2i+1])/2 This should eliminate noise.
1)你在下采样时混合了吗? y [i] =(x [2i] + x [2i + 1])/ 2这应该消除噪音。
2)How fast do you want it to be?
2)你想要多快?
3)Have you tried dynamic meanshift?(also google for dynamic x for all algorithms x)
3)你有没有尝试过动态的手段?(对于所有算法x,google也适用于动态x)
#2
2
Not sure if it is too efficient, but you could try using a Kohonen neural network (or, self-organizing map; SOM) to group the similar values, where each pixel contains the original color and position and only the color is used for the Kohohen grouping.
不确定它是否效率太高,但您可以尝试使用Kohonen神经网络(或自组织映射; SOM)对相似值进行分组,其中每个像素包含原始颜色和位置,并且只有颜色用于Kohohen分组。
You should read up before you implement this though, as my knowledge of the Kohonen network goes as far as that it is used for grouping data - so I don't know what the performance/viability options are for your scenario.
您应该在实现之前阅读,因为我对Kohonen网络的了解甚至用于分组数据 - 因此我不知道您的方案的性能/可行性选项。
There are also Hopfield Networks. They can be mangled into grouping from what I read.
还有Hopfield Networks。他们可以从我读到的内容中分组。
#3
0
What I have now:
我现在拥有的:
- Make a buffer of the same size as the input image, initialized to
UNSEGMENTED
. -
For each pixel in the image where the corresponding buffer value is not
UNSEGMENTED
, flood the buffer using the pixel value.对于图像中相应缓冲区值不是UNSEGMENTED的每个像素,使用像素值填充缓冲区。
a. The border checking of the flooding is done by checking if pixel is within
EPSILON
(currently set to 10) of the originating pixel's value.一个。通过检查像素是否在原始像素值的EPSILON(当前设置为10)内来完成泛洪的边界检查。
湾洪水填充算法。
创建与输入图像大小相同的缓冲区,初始化为UNSEGMENTED。
Possible issue:
The 2.a.'s border checking is called many times in the flood filling algorithm. I could turn it into a lookup if I could precalculate the border using edge detection, but that may add more time than current check.
在洪水填充算法中多次调用2.a.的边界检查。如果我可以使用边缘检测预先计算边界,我可以将其转换为查找,但这可能比当前检查增加更多的时间。
private boolean isValuesCloseEnough(int a_lhs, int a_rhs) {
return Math.abs(a_lhs - a_rhs) <= EPSILON;
}
Possible Enhancement:
Instead of checking every single pixel for UNSEGMENTED
, I could randomly pick a few points. If you are expecting around 10 blobs, picking random points in that order may suffice. Drawback is that you might miss a useful but small blob.
我可以随机选择一些点,而不是检查每个像素是否为UNSEGMENTED。如果你期望大约10个blob,那么按顺序选择随机点就足够了。缺点是你可能会错过一个有用但很小的blob。
#4
0
Check out Eyepatch (eyepatch.stanford.edu). It should help you during the investigation phase by providing a variety of possible filters for segmentation.
查看Eyepatch(eyepatch.stanford.edu)。它应该在调查阶段通过提供各种可能的分割过滤器来帮助您。
#5
0
An alternative to flood-fill is the connnected-components algorithm. So,
泛洪填充的替代方案是连接组件算法。所以,
- Cheaply classify your pixels. e.g. divide pixels in colour space.
- Run the cc to find the blobs
- Retain the blobs of significant size
便宜地对像素进行分类。例如划分颜色空间中的像素。
运行cc以查找blob
保留显着大小的斑点
This approach is widely used in early vision approaches. For example in the seminal paper "Blobworld: A System for Region-Based Image Indexing and Retrieval".
这种方法广泛用于早期视觉方法。例如,在开创性的论文“Blobworld:基于区域的图像索引和检索的系统”中。
#1
3
I would downsample,in colourspace and in number of pixels, use a vision method(probably meanshift) and upscale the result.
我会在colourspace和像素数量下采样,使用视觉方法(可能是meanshift)并升级结果。
This is good because downsampling also increases the robustness to noise, and makes it more likely that you get meaningful segments.
这很好,因为下采样也会增加对噪声的鲁棒性,并使您更有可能获得有意义的段。
You could use floodfill to smooth edges afterwards if you need smoothness.
如果需要平滑度,可以使用填充物来平滑边缘。
Some more thoughts (in response to your comment).
更多的想法(回应你的评论)。
1) Did you blend as you downsampled? y[i]=(x[2i]+x[2i+1])/2 This should eliminate noise.
1)你在下采样时混合了吗? y [i] =(x [2i] + x [2i + 1])/ 2这应该消除噪音。
2)How fast do you want it to be?
2)你想要多快?
3)Have you tried dynamic meanshift?(also google for dynamic x for all algorithms x)
3)你有没有尝试过动态的手段?(对于所有算法x,google也适用于动态x)
#2
2
Not sure if it is too efficient, but you could try using a Kohonen neural network (or, self-organizing map; SOM) to group the similar values, where each pixel contains the original color and position and only the color is used for the Kohohen grouping.
不确定它是否效率太高,但您可以尝试使用Kohonen神经网络(或自组织映射; SOM)对相似值进行分组,其中每个像素包含原始颜色和位置,并且只有颜色用于Kohohen分组。
You should read up before you implement this though, as my knowledge of the Kohonen network goes as far as that it is used for grouping data - so I don't know what the performance/viability options are for your scenario.
您应该在实现之前阅读,因为我对Kohonen网络的了解甚至用于分组数据 - 因此我不知道您的方案的性能/可行性选项。
There are also Hopfield Networks. They can be mangled into grouping from what I read.
还有Hopfield Networks。他们可以从我读到的内容中分组。
#3
0
What I have now:
我现在拥有的:
- Make a buffer of the same size as the input image, initialized to
UNSEGMENTED
. -
For each pixel in the image where the corresponding buffer value is not
UNSEGMENTED
, flood the buffer using the pixel value.对于图像中相应缓冲区值不是UNSEGMENTED的每个像素,使用像素值填充缓冲区。
a. The border checking of the flooding is done by checking if pixel is within
EPSILON
(currently set to 10) of the originating pixel's value.一个。通过检查像素是否在原始像素值的EPSILON(当前设置为10)内来完成泛洪的边界检查。
湾洪水填充算法。
创建与输入图像大小相同的缓冲区,初始化为UNSEGMENTED。
Possible issue:
The 2.a.'s border checking is called many times in the flood filling algorithm. I could turn it into a lookup if I could precalculate the border using edge detection, but that may add more time than current check.
在洪水填充算法中多次调用2.a.的边界检查。如果我可以使用边缘检测预先计算边界,我可以将其转换为查找,但这可能比当前检查增加更多的时间。
private boolean isValuesCloseEnough(int a_lhs, int a_rhs) {
return Math.abs(a_lhs - a_rhs) <= EPSILON;
}
Possible Enhancement:
Instead of checking every single pixel for UNSEGMENTED
, I could randomly pick a few points. If you are expecting around 10 blobs, picking random points in that order may suffice. Drawback is that you might miss a useful but small blob.
我可以随机选择一些点,而不是检查每个像素是否为UNSEGMENTED。如果你期望大约10个blob,那么按顺序选择随机点就足够了。缺点是你可能会错过一个有用但很小的blob。
#4
0
Check out Eyepatch (eyepatch.stanford.edu). It should help you during the investigation phase by providing a variety of possible filters for segmentation.
查看Eyepatch(eyepatch.stanford.edu)。它应该在调查阶段通过提供各种可能的分割过滤器来帮助您。
#5
0
An alternative to flood-fill is the connnected-components algorithm. So,
泛洪填充的替代方案是连接组件算法。所以,
- Cheaply classify your pixels. e.g. divide pixels in colour space.
- Run the cc to find the blobs
- Retain the blobs of significant size
便宜地对像素进行分类。例如划分颜色空间中的像素。
运行cc以查找blob
保留显着大小的斑点
This approach is widely used in early vision approaches. For example in the seminal paper "Blobworld: A System for Region-Based Image Indexing and Retrieval".
这种方法广泛用于早期视觉方法。例如,在开创性的论文“Blobworld:基于区域的图像索引和检索的系统”中。