使用活动轮廓时出错

时间:2016-01-02 17:18:10

标签: image matlab image-segmentation

使用活动轮廓时出错:

  

???未定义的函数或方法'activecontour'用于输入   “单一”类型的参数。

     

==>中的错误114处的Segmentasi> threshold_Callback   final = activecontour(image2,mask,100);

image1 = handles.citra1;
    level=0.008;
    bw = edge(image1,'Canny');
    axes(handles.axes2);
    imshow(bw,[]);

    %active contour
    image2 = bwdist(~bw);
    mask = zeros(size(image2));
    mask(25:end-25,25:end-25) = 1;
    final = activecontour(image2,mask , 100);
    axes(handles.axes5)
    imshow(final,[]);
    handles.data3 = final;
    guidata(hObject,handles);

我使用的是dicom文件中的图像(矢状图像)

1 个答案:

答案 0 :(得分:2)

问题是bwdist函数的输出是矩阵,activecontour函数的输入是灰度图像。因此,您需要在使用之前将矩阵转换为灰度图像。这是使用名为mat2gray的函数完成的。为此,请在使用bwdist后应用mat2gray,如下所示:

image2 = mat2gray(bwdist(~bw));

然后其余的代码工作。查看我的简单示例:

bw = zeros(200,200);
bw(50,50) = 1;
bw(50,150) = 1;
bw(150,50) = 1;
D1 = bwdist(bw);

D2 = mat2gray(D1);
mask = zeros(size(D2));
mask(25:end-25,25:end-25) = 1;
final = activecontour(D2,mask,100);

subplot(1,3,1);imshow(bw)
subplot(1,3,2);imshow(mat2gray(D1))
subplot(1,3,3);imshow(final,[]);

enter image description here

相关问题