Remove shadow and unwanted background

8 Ansichten (letzte 30 Tage)
TAN SAK JIE
TAN SAK JIE am 8 Jun. 2021
Beantwortet: Joseph Cheng am 8 Jun. 2021
How can I remove the shadow and extract only the object. I have try imadjust() . But the shadow is still there and during imbinarize(),it will include the shadow..so I cant minus it
Is it possible to make it into the desired picture ?
Before:
Desire

Antworten (1)

Joseph Cheng
Joseph Cheng am 8 Jun. 2021
to get your started you can see that the tissue and the shadow area have similar values in all the color channels. you can do a bit of comparison of each of the color channels to generate a mask of those which are not gray and white:
img = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/645980/image.jpeg');
mtemp = double(img)./median(double(img),3);
subplot(311),imagesc(mtemp)
mtemp = mtemp-1;
subplot(312),imagesc(mtemp)
mtemp2 = abs(mtemp)<=.30;
mask = all(mtemp2,3);
subplot(313),imagesc(mask)
[row col N]=size(img);
for ind = 1:3
tempimg = img(:,:,ind);
tempimg(mask) = 255;
nimg(:,:,ind) = tempimg;
end
figure,imagesc(nimg)
axis equal
axis tight
which you can use a bit of imerode, bwfill, etc to edit the mask or generate something different.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by