Remove Black Background from segmented binary image
Afficher commentaires plus anciens
how can i remove the black background after i segmented the lung ct image i need to save only lungs in another directory 

Réponse acceptée
Plus de réponses (1)
Image Analyst
le 19 Mai 2021
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 commentaires
Allie Nokhostin
le 20 Mai 2021
Image Analyst
le 22 Mai 2021
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.
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




