0

假设我有以下两个矩阵:

>> x = [1 4 3; 6 4 3; 6 9 3; 2 4 3; 5 4 0; 5 3 1; 6 4 7];
>> y = [0 0 1; 1 1 0; 1 1 0; 0 1 1; 0.2 0.8 0.54; 1 1 1; 0 0 0];

您可以将其x视为某个图像,以及y某个感兴趣区域的每个元素的隶属程度。x

假设我将那些x具有隶属度 = 1 的元素设置为1( core ),其他元素设置0如下:

x = zeros(size(y));
x(y==1) = 1;

在这种情况下,我将得到以下输出:

     0     0     1
     1     1     0
     1     1     0
     0     1     1
     0     0     0
     1     1     1
     0     0     0

现在,对于 的元素0,我将它们的值替换y为相应位置的值,如下所示:

x(x==0)=y(x==0);

现在,我选择那些被考虑但不在核心中的像素,4-neighbours如下core所示:

four_neighbourhood_pixels = imdilate(core, strel('diamond', 1)) - core;

我的问题是:我们如何选择一个p属于最小化&four_neighbourhood_pixels之间距离xcore的像素?

假设对于距离,我计算如下:

pdist([x,core],'minkowski');

假设x在前面的命令中,将 替换为对应位置zeros的隶属度值后的矩阵?y

那么,我怎样才能选择属于最小化替换零four_neighbourhood_pixels之间的距离的像素 和?xcore

谢谢。

4

1 回答 1

0

If I understand correctly, core is the following matrix:

 0     0     1
 1     1     0
 1     1     0
 0     1     1
 0     0     0
 1     1     1
 0     0     0

First find the distance between x and core.

dist=pdist([x,core],'minkowski');
dist1=squareform(dist);
[row1,row2]=find(dist1==min(dist1(:)); %interpretation: you get the minimum distance  between row1 and row2 of [x core]

Veify if my understanding is correct:

You want a pixel from x which minimizes the distance dist and it should belong to four_neighbourhood_pixels. This is the matrix [x core]

 1     4     3     0     0     1
 6     4     3     1     1     0
 6     9     3     1     1     0
 2     4     3     0     1     1
 5     4     0     0     0     0
 5     3     1     1     1     1
 6     4     7     0     0     0

Suppose you get the minimum value between 2nd row and 3rd row. Now based on this tell us what you mean by "find a pixel which minimizes..."

于 2013-02-24T03:42:14.193 回答