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?

 채택된 답변

Image Analyst
Image Analyst 2016년 4월 26일

0 개 추천

Use imread(). Then, once it's in, what value is it giving to the "transparent" pixels?

댓글 수: 6

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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 White에 대해 자세히 알아보기

질문:

2016년 4월 26일

댓글:

2016년 4월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by