如何在matlab上删除图像的阴影?

时间:2013-12-02 15:03:06

标签: matlab image-processing

How to obtain a fruit without shadow?

正如您在图像中看到的那样,我使用Otsu方法隔离对象,但阴影会使结果变为空洞。如何隔离没有阴影的物体?

1 个答案:

答案 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

结果图片: enter image description here