mask picture on other picture
2 次查看(过去 30 天)
显示 更早的评论
i had image
after some filters & operation extract the first object and become
i get this object by give its pixel to it like under
this is the code
the question can i use the image of dog (object) as a mask on the original image to crop the dog only from the original image >>>>> to use it to correlation
clc;
close all;
fontSize = 14;
[name1,path1]=uigetfile('*.*');
rgbImage=imread([path1,name1]);
figure,
subplot(2, 3, 1);
imshow(rgbImage);
text1 = sprintf('Original Color Image');
title(text1, 'FontSize', fontSize);
red=rgbImage(:,:,1);
g=rgbImage(:,:,2);
b=rgbImage(:,:,3);
templet1=rgbImage;
i1 = rgb2gray(rgbImage);
i11 = imadjust(i1);
i2 = edge(i11,'canny',0.4);
se = strel('square',2);
i22 = imclose(i2,se);
i3 = imdilate(i22,se);
i4 = imfill(i3,'holes');
BW2 = bwareaopen(i4, 1620);
d=medfilt2(BW2,[3 3]); %median filter
e=imclearborder(d, 4);
[L,NUM]=bwlabel(e,4);
object1=(L==1);
subplot(2, 3, 2);
imshow(object1);
patt=zeros([h w]);
newr=uint8(zeros([h w]));
newg=uint8(zeros([h w]));
newb=uint8(zeros([h w]));
[r,c]=find(L==1);
patt(min(r):max(r),min(c):max(c))=object1(min(r):max(r),min(c):max(c));
ind=find(patt);
newr(ind)=red(ind);
newg(ind)=g(ind);
newb(ind)=b(ind);
templet(:,:,1)=newr;
templet(:,:,2)=newg;
templet(:,:,3)=newb;
subplot(2, 3, 3),imshow(templet);
0 个评论
回答(1 个)
Image Analyst
2014-5-17
Not sure I want to answer now, with your history of deleting your past questions and replies.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!