Remove Black Background from segmented binary image
이전 댓글 표시
how can i remove the black background after i segmented the lung ct image i need to save only lungs in another directory 

채택된 답변
추가 답변 (1개)
Image Analyst
2021년 5월 19일
Images must remain rectangular so you can't "remove" the black pixels and still have an image. There has to be something there. If you want, you could crop the image, but I don't see any use in that, other than saving an insignificant amount of disk space. You can replace the 0's with nans if you want
binaryImage = double(binaryImage); % Change from logical to floating point.
binaryImage(binaryImage == 0) = nan;
Not sure what use there is for that either. What do you really want to do? Why do you think you want to do this? So let's say you could remove 0's -- what would you do with the remaining output of all 1's?
댓글 수: 2
Allie Nokhostin
2021년 5월 20일
Image Analyst
2021년 5월 22일
I don't think that is necessary. All you need is the mask saying what is lungs and what is not. Why do you think you need to erase/blacken part of the original image? You don't really need to unless you just want to see it for curiosity.
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




