基于Matlab分割的浮游生物提取
我试图从扫描图像中提取浮游生物 我用我在这里找到的技术分割浮游生物 轮廓不错,但是,现在我不知道如何提取图像,以便每个浮游生物可以单独保存。我试着使用标签,但有很多噪音,它标签每一个规格。我想知道是否有更好的方法来做到这一点 这是我的密码:基于Matlab分割的浮游生物提取,matlab,image-processing,computer-vision,image-segmentation,Matlab,Image Processing,Computer Vision,Image Segmentation,我试图从扫描图像中提取浮游生物 我用我在这里找到的技术分割浮游生物 轮廓不错,但是,现在我不知道如何提取图像,以便每个浮游生物可以单独保存。我试着使用标签,但有很多噪音,它标签每一个规格。我想知道是否有更好的方法来做到这一点 这是我的密码: I = imread('plankton_2.jpg'); figure, imshow(I), title('original image'); [~, threshold] = edge(I, 'sobel'); fudgeFactor = .5; BW
I = imread('plankton_2.jpg');
figure, imshow(I), title('original image');
[~, threshold] = edge(I, 'sobel');
fudgeFactor = .5;
BWs = edge(I,'sobel', threshold * fudgeFactor);
figure, imshow(BWs), title('binary gradient mask');
se90 = strel('line', 3, 90);
se0 = strel('line', 3, 0);
BWsdil = imdilate(BWs, [se90 se0]);
figure, imshow(BWsdil), title('dilated gradient mask');
BWdfill = imfill(BWsdil, 'holes');
figure, imshow(BWdfill);
title('binary image with filled holes');
BWnobord = imclearborder(BWdfill,1);
figure, imshow(BWnobord), title('cleared border image');
seD = strel('diamond',1);
BWfinal = imerode(BWnobord,seD);
BWfinal = imerode(BWfinal,seD);
figure, imshow(BWfinal), title('segmented image');
BWoutline = bwperim(BWfinal);
Segout = I;
Segout(BWoutline) = 0;
figure, imshow(Segout), title('outlined original image');
label = bwlabel(BWfinal);
max(max(label))
for j = 1:max(max(label))
[row, col] = find(label == j);
len = max(row) - min(row)+2;
breadth = max(col)-min(col) +2;
target = uint8(zeros([len breadth]));
sy = min(col)-1;
sx = min(row)-1;
for i = 1:size(row,1)
x = row(i,1)-sx;
y = col(i,1) - sy;
target(x,y)=I(row(i,1),col(i,1));
end
mytitle =strcat('Object Number:',num2str(j));
figure, imshow(target);mytitle;
end
for j = 1:max(max(label))
[row, col] = find(label == j);
len = max(row) - min(row)+2;
breadth = max(col)-min(col) +2;
target = uint8(zeros([len breadth]));
sy = min(col)-1;
sx = min(row)-1;
for i = 1:size(row,1)
x = row(i,1)-sx;
y = col(i,1) - sy;
target(x,y)=I(row(i,1),col(i,1));
end
mytitle =strcat('Object Number:',num2str(j));
figure, imshow(target);mytitle;
end
您应该使用
regionprops
功能按大小和/或形状特征过滤检测到的对象。我使用regionprops得到了这个结果。谢谢你的建议。