clc;
clear all;
%reading and showing
f1=imread('foreground.jpg');
%converting color image to grayimage
f2=rgb2gray(f1);
figure(1),imshow(f2);
%reading and showing
f3=imread('background.jpg');
%converting color image to grayimage
f4=rgb2gray(f3);
figure(2),imshow(f4);
%background subtracting
f5=abs(double(f2)-double(f4));
[M N]=size(f5);
T=20;
for i=1:M
for j=1:N
if f5(i,j)>T
f5(i,j)=255;
else
f5(i,j)=0;
end
end
end
f5=uint8(f5);
figure(3);
imshow(f5);
% imclose the image
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载