BW2 = bwareaopen(BW,P,conn)
作用:
作用:
删除二值图像BW中面积小于P的对象,默认情况下conn使用8邻域。
算法:
(1)Determine the connected components.
L = bwlabeln(BW, conn);
(2)Compute the area of each component.
S = regionprops(L, 'Area');
(3)Remove small objects.
bw2 = ismember(L, find([S.Area] >= P));
算法:
(1)Determine the connected components.
L = bwlabeln(BW, conn);
(2)Compute the area of each component.
S = regionprops(L, 'Area');
(3)Remove small objects.
bw2 =
label2rgb() 功能:转换标记矩阵到RGB图像。即根据标记矩阵不同的值,转变为不同的颜色或灰度。 调用格式之一RGB = label2rgb(L, map, zerocolor) ;即为题目中的形式 其中, L为要转换的标记矩阵, map可取值为@jet或者@gray,@gray为灰度条,@jet为彩色条,即变为彩色图像,@jet表示通过jet的句柄引用'jet' map。 zerocolor为标记0的颜色,[.5 .5 .5]即将标记0的颜色设为[0.5 0.5 0.5]。缺省值为[1 1 1],即白色bwdist是距离变换函数,如果不提供第二参数method,默认计算二值图中当前像素点与最近的非0像素点的距离,并返回与原二值图同大小的结果矩阵,如果返回值指定为2个,第二返回值是与当前位置最近的非0像素的一维坐标(列优先存储).
下面说说如何对matlab提速的问题,我会使用两个例子来说明。
【例1】任务描述:根据A的取值使用imshow函数显示矩阵B
A = randn(100, 100);
B = zeros(size(A));
【方案1】
[X,Y] = find(A > 0.6);
For i = 1:length(X)
B(X(i),Y(i)) = 1;
End
【方案 2】
B = zeros(size(A));
X = find(A > 0.6);
B(X) = 1;
【方 案3】:
B = zeros(size(A));
X = logical(A > 0.6);
B(X) = 1;
【方案1】
iTotalVoxel = 61*73*61;
for k = 1:iTotalVoxel
if C(k) == 1
temp = B(k,: );
imf = emd(t, temp);
…
end
end
【方案2】
D = find(C);
iTotalBrainVoxel = length(D);
for k = 1: iTotalBrainVoxel
temp = B(D(k),: );
imf = emd(t, temp);
…
end
iTotalVoxel = 61*73*61;
for k = 1:iTotalVoxel
if C(k) == 1
temp = B(k,: );
imf = emd(t, temp);
…
end
end
【方案2】
D = find(C);
iTotalBrainVoxel = length(D);
for k = 1: iTotalBrainVoxel
temp = B(D(k),: );
imf = emd(t, temp);
…
end