How do I read image with transparent background in MATLAB code?

I am analyzing an image using a code. My images have an object with transparent background. How do I make the code read the object region and leave out the background?

 Réponse acceptée

Image Analyst
Image Analyst le 26 Avr 2016
Use imread(). Then, once it's in, what value is it giving to the "transparent" pixels?

6 commentaires

Yes, It is giving the "Blue" to transparent. That screws up transparent with white.
How are you displaying it? You should be using imshow(). It sounds like maybe you're using imagesc() which applies some weird colormap by default for some reason. Don't use imagesc(), use imshow(). If you do want a colormap for some reason, you can still use it with imshow() - just call colormap() and pass it some colormap that you like. You can also call colorbar to put a color ramp alongside the image.
But I was talking about what the value is in your array if you look at it in the workspace variable inspector. Like if the upper left pixel is transparent, what is its value?
It is [0,0,0] before process and after process coverts to RGB: [0,0,0.562]. BTW, yes I was using "imagesc". I have used imshow instead, but still no luck.
What does this say
whos yourImageArray
And what do you mean by "after process"? What process? What is changing the 0 to 0.562?
I have applied your advice "Don't use imagesc(), use imshow(). If you do want a colormap for some reason, you can still use it with imshow() - just call colormap() and pass it some colormap that you like" and it worked.
Thanks
Glad it worked for you. Please don't delete this question since it might help someone else some day.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by