gpt4 book ai didi

matlab - 使用 Matlab 分割提取浮游生物

转载 作者:太空宇宙 更新时间:2023-11-03 19:46:26 24 4
gpt4 key购买 nike

我正在尝试从扫描图像中提取浮游生物。 scanned image

我使用在这里找到的技术对浮游生物进行了分割,http://www.mathworks.com/help/images/examples/detecting-a-cell-using-image-segmentation.html

轮廓还不错,但是,现在我不确定如何提取图像以便单独保存每个浮游生物。我尝试使用标签,但噪音很大,而且它会标记每个规范。我想知道是否有更好的方法来做到这一点。

这是我的代码:

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 函数按大小和/或形状特征过滤检测到的对象。

关于matlab - 使用 Matlab 分割提取浮游生物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36869945/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com