How can I remove the background from the image?
3 views (last 30 days)
Show older comments
I made a phantom image in Matlab by using this function P=phantom(256); figure, imshow(P);
if I want to remove the background color " Black " and keep the remaining picture, what can I do to remove it or make it as transparent image ???
0 Comments
Answers (1)
Image Analyst
on 14 Dec 2014
You cannot "remove" the black (outside the white ring) because an image must remain rectangular. The best you can do is to crop it to the bounding rectangle. Do you want to do that? Anyway, there is no need to remove it. You can measure whatever you want on the rest of the regions in the image without "removing" the black pixels. What do you want to do anyway? I can show you how you can do it without removing the black or making it transparent if you'll only tell me. If you want you can replace the black with something else, like a uniform gray level or even some other image. I can show you how to do that if you provide the gray level or the other background image.
3 Comments
Image Analyst
on 15 Dec 2014
Same answer. You cannot have circular images. You cannot do what you want to do. You can crop (which you say is "insufficient" for some reason) but it's really not necessary. Why do you think it is?
Why do you have a goal to make the image perfectly circular? What good will that do?
Brian Peoples
on 26 Jun 2020
My question is similar @Image Analyst if you see my most recent post @ https://www.mathworks.com/matlabcentral/answers/555364-how-to-remove-black-background-from-photo-only-keep-region-of-interest
but I am okay with only using the area of interest for getting the average lightness values I desire and keeping the black background if necessary.
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!