Remove shadow and unwanted background
조회 수: 11 (최근 30일)
이전 댓글 표시
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:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/645980/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/645980/image.jpeg)
Desire
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/645985/image.png)
댓글 수: 0
답변 (1개)
Joseph Cheng
2021년 6월 8일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!