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!




