Azzera filtri
Azzera filtri

Remove shadow and unwanted background

6 visualizzazioni (ultimi 30 giorni)
TAN SAK JIE
TAN SAK JIE il 8 Giu 2021
Risposto: Joseph Cheng il 8 Giu 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

Risposte (1)

Joseph Cheng
Joseph Cheng il 8 Giu 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.

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by