图像处理:从图像中分割 "zebra"

Image Processing :Segmenting "zebra" out of image

嘿,我正在尝试解决这个问题。要求您从图像中分割出 "zebra" 的位置。下面是给定的图像。

输出应该是这样的。

好吧,我卡在了 "strips" 斑马线,因为它们可能会被分割为单独的对象。

在图像处理中,重要的是查看您的图像并尝试了解您感兴趣的区域(即斑马)与其余区域(即背景)之间的差异。

在这个例子中,一个明显的区别是背景偏绿而斑马是黑白的。因此,图像的绿色通道可以用来提取背景。之后,可以使用一些膨胀和腐蚀步骤(非线性地)清理结果。

一种简单且不完美的分割技术是(在 Matlab 中):

I = imread('lA196m.jpg');

% plot the original image
figure
subplot(2,2,1)
imshow(I)

% calculate the green channel (relative green value)
greenChannel = double(I(:,:, 2))./mean(I(:,:,:), 3);
binary = greenChannel > 1; % apply a thresshold
subplot(2,2,2)
imshow(binary);

% remove false positives (backgrounds)
se1 = strel('sphere',20);
binary2 = imdilate(imerode(binary,se1), se1);
subplot(2,2,3)
imshow(binary2);

% add false negatives
se2 = strel('sphere',10);
binary3 = imerode(imdilate(binary2,se2), se2);
subplot(2,2,4)
imshow(binary3);

% calculate & plot the boundary on the original image
subplot(2,2,1)
Bs = bwboundaries(~binary3);
B = Bs{1};
hold on
plot(B(:, 2), B(:, 1), 'LineWidth', 2);