Problems with using colormap commands in gui matlab

Hi,
After several research online, i still have a doubt about this command:
-----------------
load flujet
image(X)
colormap(jet)
--------------
I have seen several example of this. However, from what i have noticed that we can only use the load commands if the image is in the .mat file. Is there any other ways for me to read an image using other commands?
Thanks!!

回答(1 个)

Walter Roberson
Walter Roberson 2012-10-19
编辑:Walter Roberson 2012-10-19
imread(), or mmread() or the avifile class [to read images], or the I/O operations such as fread() if the image is stored as a binary file.
Or compute the image.
The colormap() command is completely independent of how you get the data into MATLAB.

8 个评论

so, by that, i should use imread command instead? i have try this command. nevertheless, i still receive an error.
------------------------------------------
A = imread(handles.currentimage);
axes(A,handles.axes4);
colormap('gray');
------------------------------------------
Thanks for the reply. Pls help me again!
What is the complete error message?
These are the errors:
---------------------------
??? Error using ==> strfind Input strings must have one row.
Error in ==> imread at 342 if (strfind(filename, '://'))
Error in ==> New>pixelButton_Callback at 302 A = imread(handles.currentimage);
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> New at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)New('pixelButton_Callback',hObject,eventdata,guidata(hObject))
??? Error using ==> waitfor Error while evaluating uicontrol Callback
Well then it appears that handles.currentimage is neither a string (filename), not a numerical array (an image). What does it say when you over the mouse over that when you stop there for a breakpoint?
im sorry, but i could not understand your question. Please rephrase that for me? Thanks!
OK, you need to learn how to use the debugger. How to set breakpoints, how to examine the values of variables, how to step through lines of code, that kind of thing. It's mandatory that you learn this. I know you don't know how yet, or else you would have understood what I said. You won't progress very far in MATLAB unless you learn how to debug your programs.
Okay, i have did as what you have said. i have set the breaking point. and these are the error:
---------------------------------
304 A = imread(handles.currentimage); ??? Error using ==> strfind Input strings must have one row.
Error in ==> imread at 342 if (strfind(filename, '://'))
Error in ==> New>pixelButton_Callback at 304 A = imread(handles.currentimage);
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> New at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)New('pixelButton_Callback',hObject,eventdata,guidata(hObject))
??? Error using ==> waitfor Error while evaluating uicontrol Callback
OK, now that you've learned how to use the debugger, let's get back to my original question "What does it say when you over the mouse over that when you stop there for a breakpoint?" In other words, what is the value of handles.currentimage? There are many ways you can see the value of handles.currentimage, as you now know. I'll review them.. If you don't want to hover the mouse over it, then click in it and type control-D, or double-click on its name in the workspace, or just type it into the command window and hit enter. OK, so what does it say the value is? Is it either a valid filename string, or a numerical array?

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Orange 的更多信息

产品

提问:

sha
2012-10-19

Community Treasure Hunt

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

Start Hunting!

Translated by