【发布时间】:2016-06-07 09:30:44
【问题描述】:
搜索了 2 或 3 天后,我仍然没有找到解决问题的方法。
我想创建一个没有阴影的鼠标分割。问题是如果我设法去除阴影,我也会去除尾巴和脚,这是一个问题。阴影来自鼠标所在的竞技场的墙壁。
我想从灰度图像中移除阴影,但我不知道该怎么做。首先我去掉了图片的背景,得到了下面的图片。
edit1:感谢您的回答,当阴影不接触鼠标时效果很好。这就是我得到的:
来自这个原始图像:
我正在从 tif 文件中提取每一帧,并为每一帧应用您的代码。这是我使用的代码:
for k=1:1000
%reads image
I = imread('souris3.tif',k);
%first stage: perform thesholding and fill holes
seg = I >20000;
seg = imfill(seg,'holes');
%fixes the missing tail problem
%extract edges, and add them to the segmentation.
edges = edge(I);
seg = seg | edges;
%fill holes (again)
seg = imfill(seg,'holes');
%find all the connected components
CC = bwconncomp(seg,8);
%keeps only the biggest CC
numPixels = cellfun(@numel,CC.PixelIdxList);
[biggest,idx] = max(numPixels);
seg = zeros(size(edges));
seg(CC.PixelIdxList{idx}) = 1;
imshow(seg);
end
我使用命令impixelinfo 选择20000 作为步长,因为图像在uint16 中,它是鼠标的平均值。
如果你想拥有 tif 文件,这是链接:
感谢您的帮助。
【问题讨论】:
标签: matlab image-processing shadow image-segmentation