对该图片进行背景风
clear all;
close all;
clc;
I=imread('Weed2.jpeg');
Ir=I(:,:,1);
Ig=I(:,:,2);
Ib=I(:,:,3);
figure,
subplot(2,2,1),imshow(I),title('原图');
subplot(2,2,2),imshow(Ir),title('r');
subplot(2,2,3),imshow(Ig),title('g');
subplot(2,2,4),imshow(Ib),title('b');
Irg=Ir-Ig;
figure,
subplot(2,2,1),imshow(Irg);
subplot(2,2,2),imhist(Irg);
subplot(2,2,3),imtool(Irg);
bw=im2bw(Irg,7/125);
figure,imshow(bw);
imgComplement = imcomplement(bw);
figure,imshow(imgComplement);
bw=bwareaopen(imgComplement,100);
objr=uint8(bw).*Ir;
objg=uint8(bw).*Ig;
objb=uint8(bw).*Ib;
obj=cat(3,objr,objg,objb);
figure,imshow(obj);
figure,
subplot(1,2,1),imshow(I),title('原图');
subplot(1,2,2),imshow(obj),title('提取');
该图片进行背景分割