mask picture on other picture
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 17 May 2014
Not sure I want to answer now, with your history of deleting your past questions and replies.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!