removal of shadow area

조회 수: 3 (최근 30일)
SHOBA MOHAN
SHOBA MOHAN 2018년 1월 7일
댓글: Monisha Gowda 2020년 4월 12일
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
SHOBA MOHAN
SHOBA MOHAN 2018년 1월 8일
Sorry for inconvenience now I am attaching foreground image. Thanks for the response.
Monisha Gowda
Monisha Gowda 2020년 4월 12일
Hi, Have you done it. I am also looking for the same. Can you help me on this?

댓글을 달려면 로그인하십시오.

답변 (1개)

Malhar Ashtaputre
Malhar Ashtaputre 2018년 1월 8일
Kindly go through following link for help in shadow removing:
  댓글 수: 1
Maisha Maimuna
Maisha Maimuna 2019년 9월 8일
Hello Malhar Ashtaputre,
have you got the solution? I am stuck with the same problem.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by