el-Hakeem
el-Hakeem

Reputation: 57

How to remove shadow of image on matlab?

How to obtain a fruit without shadow?

As you can see in image, I isolate objects using Otsu method, but shadows make the result innacurate. How to isolate object without shadow?

Upvotes: 0

Views: 7786

Answers (1)

lennon310
lennon310

Reputation: 12689

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

Result image: enter image description here

Upvotes: 1

Related Questions