removal of shadow area

2 vues (au cours des 30 derniers jours)
SHOBA MOHAN
SHOBA MOHAN le 7 Jan 2018
Commenté : Monisha Gowda le 12 Avr 2020
I have used adaptive thresholding technique to distinguish foreground and background pixel as per the attachment in the link. https://www.mathworks.com/matlabcentral/fileexchange/8647-local-adaptive-thresholding?focused=6119920&tab=function
I have incorporated connected component analysis to the threshold coding.
I am attaching input and thresholded image here. Can anyone suggest me how to remove the shadow part alone.
function bw=adaptivethreshold(IM,ws,C,tm)
if (nargin<3)
error('You must provide the image IM, the window size ws, and C.');
elseif (nargin==3)
tm=0;
elseif (tm~=0 && tm~=1)
error('tm must be 0 or 1.');
end
IM=mat2gray(IM);
if tm==0
mIM=imfilter(IM,fspecial('average',ws),'replicate');
else
mIM=medfilt2(IM,[ws ws]);
end
sIM=mIM-IM-C;
bw=im2bw(sIM,0);
bw=imcomplement(bw);
Test Code:
clear;
close all;
% im1=imread('inputimage.jpg');
im2=imread('foregroundimage.jpg');
% bwim1=adaptivethreshold(im1,11,0.03,0);
bwim2=adaptivethreshold(im2,15,0.02,0);
% ModeFilterFunction = @(x) mode(x(:));
% modeImage = nlfilter(bwim2, [3 3], ModeFilterFunction);
CC = bwconncomp(bwim2,8);
S = regionprops(CC, 'Area');
L = labelmatrix(CC);
BW2 = ismember(L, find([S.Area] >= 100));
subplot(2, 2, 3);
imshow(BW2, []);
subplot(2,2,1);
imshow(im2);
subplot(2,2,2);
imshow(bwim2);
  3 commentaires
SHOBA MOHAN
SHOBA MOHAN le 8 Jan 2018
Sorry for inconvenience now I am attaching foreground image. Thanks for the response.
Monisha Gowda
Monisha Gowda le 12 Avr 2020
Hi, Have you done it. I am also looking for the same. Can you help me on this?

Connectez-vous pour commenter.

Réponses (1)

Malhar Ashtaputre
Malhar Ashtaputre le 8 Jan 2018
Kindly go through following link for help in shadow removing:
  1 commentaire
Maisha Maimuna
Maisha Maimuna le 8 Sep 2019
Hello Malhar Ashtaputre,
have you got the solution? I am stuck with the same problem.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by