필터 지우기
필터 지우기

imread png vs gif

조회 수: 1 (최근 30일)
John
John 2015년 2월 19일
댓글: Image Analyst 2015년 2월 21일
It looks imread .gif and .png are different. Please help to read the image right.
[X,map] = imread('matlabicon.gif');
icon = ind2rgb(X,map);
% X is 16x16, map is 127x3
image(icon);
image(icon) looks good!
However:
[X,map] = imread('open_file.png');
% X is 16x16x3, map=[]
icon = ind2rgb(X,map);
% doesn't work as map=[] and X is already 3 dimensions
image(X) doesn't look the same image at all! White pixels became black.
====
Added on after a while:
OK, I did this, and it looks about right. CData in uipushtool shows correctly:
X(X==0)=max(X(:));
icon = double(X)/double(max(X(:)));
But it doesn't look elegant and generally right.
What's the right way of reading all image format for image(X) and CData in uipushtool?

답변 (1개)

Image Analyst
Image Analyst 2015년 2월 19일
Please attach your open_file.png file so we can help you. If X is already an RGB image (16x16x3) then a colormap does not even apply, and you certainly shouldn't use ind2rgb() on an image that is ALREADY RGB.
  댓글 수: 2
John
John 2015년 2월 19일
All files are in: C:\Program Files\MATLAB\"R2013b"\toolbox\matlab\icons
Image Analyst
Image Analyst 2015년 2월 21일
open_file.png is not in R2013b. It must have been something you added. It doesn't ship with MATLAB because I don't have it and I have that version and also the latest R2014b and it's not in that either. Please attach your open_file.png file so we can help you.

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

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by