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