How can I remove shadows in image segmentation?

5 views (last 30 days)
I'm a beginner user of MATLAB. I'm working on a project about fruit segmentation. I took pictures of different fruits with a white background. I used HSV thresholding, then morphologic operations. My problem is that i'm not be able to remove shadows in inferior part so this makes the object bigger than real and my results are not so accurate.
Do you have ave any suggestions? Should I use different threshold?
I = imread('limone_prova.jpg');
if true
clc;
clear all;
close all;
workspace;
I = imread('limone_prova2.jpg'); figure(1); imshow (I,'InitialMagnification',17)
%crop I_crop=imcrop(I, [873.5 411.5 2910 2232]);
I_HSV=rgb2hsv(I_crop); H=I_HSV(:,:,1); %Hue S=I_HSV(:,:,2); %Saturation V=I_HSV(:,:,3); %Value
thr_S=(S > 0.20);
open_S = bwareaopen(thr_S, 6000);
se = strel('disk',15); closeMask = imclose(open_S, se);
mask = uint8(closeMask); mask = cast(mask, class(I_crop)); mask_R = mask .* I_crop(:,:,1); mask_G = mask .* I_crop(:,:,2); mask_B = mask .* I_crop(:,:,3); mask_RGB = cat(3, mask_R, mask_G, mask_B);
figure; imshow(mask_RGB) end

Accepted Answer

Payam Ahmadvand
Payam Ahmadvand on 3 May 2015
Shadow removing is a challenging topics and you cannot remove the shadow just by a threshold!
A method base on segmentation "The Shadow Meets the Mask: Pyramid-Based Shadow Removal" www.cs.huji.ac.il/~danix/ShadowRemoval/shadow_eg08.pdf
A method based on entropy minimization "Recovery of Chromaticity Image Free from Shadows via Illumination Invariance" https://www.cs.sfu.ca/~mark/ftp/Iccv03ColorWkshp/iccv03wkshp.pdf
  2 Comments
emmegi
emmegi on 3 May 2015
Thank you for your suggestions, I'll study this papers and I'll try to fix the problem.
hoyzer24
hoyzer24 on 17 Sep 2015
You found some answers concerning this? I would also be interested ;)

Sign in to comment.

More Answers (0)

Categories

Find more on Modify Image Colors in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!