正如您在图像中看到的那样,我使用Otsu方法隔离对象,但阴影会使结果变为空洞。如何隔离没有阴影的物体?
答案 0 :(得分:1)
I = imread('YgmAf.jpg'); % your original image
imagesc(I)
I=rgb2hsv(I);
I1=I(:,:,2); % change to hsv and select the channel with most clear contrast between object and shadow
thresholded = I1 > 0.23; %% Threshold to isolate lungs
thresholded = bwareaopen(thresholded,100); % remove too small pixels
I2=thresholded.*I1;
I3=edge(I2,'canny',graythresh(I2)); % ostu method
I3 = imfill(I3,'hole');
figure,imagesc(I3) %object binary image
结果图片: