Adding image on gui without using image processing toolbox

1 回表示 (過去 30 日間)
Shyam
Shyam 2013 年 4 月 11 日
I want to add a .png / .jpg / .tif file on gui....without using imshow in image processing toolbox
CODE SEGMENT UNDER OPENING FUNC:
fig = handles.figure1;
axes(handles.axes1) [X,map] = imread('blkdiag.tif','tif'); IMG = ind2rgb(X,map); image(IMG);
ERROR MESSAGE:
Index exceeds matrix dimensions.
Error in ind2rgb (line 27) r = zeros(size(a)); r(:) = cm(a,1);
Error in dtc>dtc_OpeningFcn (line 62) IMG = ind2rgb(X,map);
Error in gui_mainfcn (line 221) feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
Error in dtc (line 42) gui_mainfcn(gui_State, varargin{:});
Pls guide me on the standard way of doing this...also pls keep in mind that i don have image processing toolbox

採用された回答

Image Analyst
Image Analyst 2013 年 4 月 11 日
Are you sure it's an indexed image? If so, what are the values of map? What size is it? Do this
whos X
whos map
Tell us what you see in the command window.
  1 件のコメント
Image Analyst
Image Analyst 2013 年 4 月 11 日
編集済み: Image Analyst 2013 年 4 月 11 日
Of course, MATLAB handles PNG files just fine. It's becoming the new favorite format for most people. It's got everything you need, lossless compression, wide acceptance, etc. What's not to like? No need to try to convert your PNG files into TIF files for MATLAB's use. Really, no need, so don't do it. Just read the PNG files directly.
theImage = imread(fullPNGFileName);
imshow(theImage);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by