采用均值漂移图像分割解释均值、图像

2023-09-10 22:46:13 作者:ー克拉的眼泪

任何人都可以请帮助我了解如何均值漂移分割的实际工作?

Could anyone please help me understand how Mean Shift segmentation actually works?

下面是我只是做了一个8×8矩阵

Here is a 8x8 matrix that I just made up

  103  103  103  103  103  103  106  104   
  103  147  147  153  147  156  153  104   
  107  153  153  153  153  153  153  107   
  103  153  147  96   98   153  153  104   
  107  156  153  97   96   147  153  107   
  103  153  153  147  156  153  153  101   
  103  156  153  147  147  153  153  104   
  103  103  107  104  103  106  103  107

使用上面的基质是有可能解释移位如何平均数分割将分出3个不同层次号码?

Using the matrix above is it possible to explain how Mean Shift segmentation would separate the 3 different levels of numbers?

推荐答案

基础知识第一:

均值漂移分割是一个本地同质化技术,是阻尼阴影或色调差异,本地化的对象非常有用的。 一个例子是不是很多的话更好的:

The Mean Shift segmentation is a local homogenization technique that is very useful for damping shading or tonality differences in localized objects. An example is better than many words:

操作:替换在一系列-R附近的像素的平均每一个像素,其值是在一个距离d

均值漂移通常需要3个输入:

The Mean Shift takes usually 3 inputs:

的距离测量功能的像素之间的距离。一般的欧几里得距离,但任何其它公定义距离函数也可以使用。该曼哈顿 距离是另一种有用的选择的时候。 半径。这个半径(根据上述的距离测量)内的所有像素将被占计算。 的数值差异。从半径r内的所有像素,我们将只需要那些值是这种差异在计算平均值 A distance function for measuring distances between pixels. Usually the Euclidean distance, but any other well defined distance function could be used. The Manhattan Distance is another useful choice sometimes. A radius. All pixels within this radius (measured according the above distance) will be accounted for the calculation. A value difference. From all pixels inside radius r, we will take only those whose values are within this difference for calculating the mean

请注意,该算法是不明确定义的边界,所以不同的实施将给你不同的结果存在。

Please note that the algorithm is not well defined at the borders, so different implementations will give you different results there.

我就不在这里讨论了血淋淋的数学细节,因为它们是不可能的,没有适当的数学符号来显示,而不是用在计算器,也因为他们可以找到from其他地方的良好来源。

I'll NOT discuss the gory mathematical details here, as they are impossible to show without proper mathematical notation, not available in StackOverflow, and also because they can be found from good sources elsewhere.

让我们来看看你的中心矩阵的:

Let's look at the center of your matrix:

153  153  153  153 
147  96   98   153 
153  97   96   147   
153  153  147  156  

随着半径和距离的合理选择,这四个中心的像素将获得97(其平均值)的值,将不同形式的相邻像素。

With reasonable choices for radius and distance, the four center pixels will get the value of 97 (their mean) and will be different form the adjacent pixels.

让我们来计算它在数学。相反,显示实际数字,我们会显示一个颜色编码,所以它更容易理解发生了什么:

Let's calculate it in Mathematica. Instead of showing the actual numbers, we will display a color coding, so it's easier to understand what is happening:

颜色编码的矩阵是:

然后我们采取了合理的均值漂移:

Then we take a reasonable Mean Shift:

MeanShiftFilter[a, 3, 3]

和我们得到:

如果所有的中心元素相等(97,BTW)。

Where all center elements are equal (to 97, BTW).

您可以重复几次均值漂移,试图获得更均匀的着色。经过几次迭代,则到达一个稳定的非各向同性的配置:

You may iterate several times with Mean Shift, trying to get a more homogeneous coloring. After a few iterations, you arrive at a stable non-isotropic configuration:

在这个时候,应该清楚,你无法选择你申请平均后移多少色获得。因此,让我们展示如何做到这一点,因为那是你的问题的第二部分。

At this time, it should be clear that you can't select how many "colors" you get after applying Mean Shift. So, let's show how to do it, because that is the second part of your question.

您有什么需要可以设置输出簇的数目提前有点像 k均值聚类。

What you need to be able to set the number of output clusters in advance is something like Kmeans clustering.

它运行这种方式为你的矩阵:

It runs this way for your matrix:

b = ClusteringComponents[a, 3]

{{1, 1, 1, 1, 1, 1, 1, 1}, 
 {1, 2, 2, 3, 2, 3, 3, 1}, 
 {1, 3, 3, 3, 3, 3, 3, 1}, 
 {1, 3, 2, 1, 1, 3, 3, 1}, 
 {1, 3, 3, 1, 1, 2, 3, 1}, 
 {1, 3, 3, 2, 3, 3, 3, 1}, 
 {1, 3, 3, 2, 2, 3, 3, 1}, 
 {1, 1, 1, 1, 1, 1, 1, 1}}  

或者

这非常类似于我们previous的结果,但是你可以看到,现在我们只有三个输出电平。

Which is very similar to our previous result, but as you can see, now we have only three output levels.

心连心!