【发布时间】:2013-12-27 20:56:04
【问题描述】:
我在图像上应用了 srm 算法来平滑图像中每个对象的颜色,以便提取它,然后我调用函数 extractLabel 来提取单独帧中的每个彩色区域。目前,这工作正常,但问题是当我想获得与提取的彩色区域匹配的原始部分时,我没有成功。
例如:这是原始图像
这是应用 srm 算法后的结果:
提取结果:
现在,我怎样才能从原始图像中获取这些部分??? 我是否使用了正确的技术?
我用于提取每个彩色区域的代码:
function extractLabel(originalImage,I)
% I is the srm result image
[Iu,ia,iu] = unique(reshape(I,[],3),'rows');
counts = accumarray(iu,1);
[counts,sortinds] = sort(counts,'descend');
N = 10;
largestLabels = sortinds(1:N);
for i= 1:6
mapi = reshape(iu == largestLabels(i),size(I,1),size(I,2));
[L,Total] = bwlabel(mapi);
Sdata=regionprops(L,'BoundingBox');
for j=1:Total
Img=imcrop(I,Sdata(j).BoundingBox);
Name=strcat('Object Number:',num2str(j));
end
figure(1)
subplot(2,3,i);
imshow(Img, 'border', 'tight');
figure(2)
subplot(2,3,i);
imshow(L==0, 'border', 'tight');
im_name=strcat('image',num2str(i),'.png');
imwrite(L==0,im_name)
end
【问题讨论】:
标签: matlab image-processing extraction image-segmentation