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 件のコメント

SASA
SASA 2016 年 4 月 26 日
Yes, It is giving the "Blue" to transparent. That screws up transparent with white.
Image Analyst
Image Analyst 2016 年 4 月 26 日
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?
SASA
SASA 2016 年 4 月 26 日
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.
Image Analyst
Image Analyst 2016 年 4 月 26 日
What does this say
whos yourImageArray
And what do you mean by "after process"? What process? What is changing the 0 to 0.562?
SASA
SASA 2016 年 4 月 26 日
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
Image Analyst
Image Analyst 2016 年 4 月 27 日
Glad it worked for you. Please don't delete this question since it might help someone else some day.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

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