How to insert a picture in to a GUI

  • Follow


I try to add a picture into a GUI. But I couldn't figure it out. Someone can help me out? (this picture can be .fig, bmp, or jpg format). One way I try to use image command to draw the picture in the axes handle of the GUI, but the picture isn't show very well (picture's colour is changed)

Thanks
0
Reply yan 12/14/2010 10:00:22 AM

"yan huang" <yan.huang1@unsw.edu.au> wrote in message <ie7f7m$r38$1@fred.mathworks.com>...
> I try to add a picture into a GUI. But I couldn't figure it out. Someone can help me out? (this picture can be .fig, bmp, or jpg format). One way I try to use image command to draw the picture in the axes handle of the GUI, but the picture isn't show very well (picture's colour is changed)
> 
> Thanks

You can find it in:

http://blogs.mathworks.com/pick/2007/10/16/matlab-basics-setting-a-background-image-for-a-gui/

Have fun!
0
Reply Diego 12/14/2010 11:10:22 AM


On Dec 14, 5:00=A0am, "yan huang" <yan.hua...@unsw.edu.au> wrote:
> I try to add a picture into a GUI. But I couldn't figure it out. Someone =
can help me out? (this picture can be .fig, bmp, or jpg format). One way I =
try to use image command to draw the picture in the axes handle of the GUI,=
 but the picture isn't show very well (picture's colour is changed)
>
> Thanks

---------------------------------------------------------------------------
Try MAGIC:
http://www.mathworks.com/matlabcentral/fileexchange/24224
Description

This GUI will help the novice user get up to speed very quickly on
using GUI-based applications. Everything is laid out in a very simple
Step 1, Step 2, Step 3, etc. layout. It is a very good starting point
for a typical image analysis application. This application uses GUIDE
to do the user interface design, and has most of the basic controls
such as buttons, listboxes, checkboxes, radio buttons, scrollbars,
etc. It allows the user to select a folder of images, select one or
more images and display them, to select a series of options, and to
individually or batch process one or more images. The user can
optionally apply a mask (region of interest) to the image so that only
the area within the mask will be analyzed. The results are optionally
sent to Excel. In this demo, I do some very basic particle sizing but
in use, the user would replace that simple demo code in the function
AnalyzeSingleImage() with their own code. Works with Windows or Unix
since paths are all forward slashes. Requires the Image Processing
Toolbox to do the simple particle sizing demo, but if you delete that
demo code before using it, then the IP toolbox would not be required
and it would still demonstrate the basic GUI-based file processing
functionality.
0
Reply ImageAnalyst 12/14/2010 11:24:43 AM

"Diego calatrabas" <diegoobradors@gmail.com> wrote in message <ie7jat$5oa$1@fred.mathworks.com>...
> "yan huang" <yan.huang1@unsw.edu.au> wrote in message <ie7f7m$r38$1@fred.mathworks.com>...
> > I try to add a picture into a GUI. But I couldn't figure it out. Someone can help me out? (this picture can be .fig, bmp, or jpg format). One way I try to use image command to draw the picture in the axes handle of the GUI, but the picture isn't show very well (picture's colour is changed)
> > 
> > Thanks
> 
> You can find it in:
> 
> http://blogs.mathworks.com/pick/2007/10/16/matlab-basics-setting-a-background-image-for-a-gui/
> 
> Have fun!
Hi Diego,
I can use the method at home, but cannot use in my school. In shcool, I use Matlab R2009a that show error message 
??? Undefined function or method 'imshow' for input arguments of type 'char', 
while at home I use Matlab R2007 which have function 'imshow'.
Does any function replace 'imshow' funciton in Matlab2009a?

Thank you, 
0
Reply yan 12/14/2010 11:52:05 PM

On 10-12-14 05:52 PM, yan huang wrote:

> I can use the method at home, but cannot use in my school. In shcool, I use
> Matlab R2009a that show error message ??? Undefined function or method
> 'imshow' for input arguments of type 'char', while at home I use Matlab R2007
> which have function 'imshow'.
> Does any function replace 'imshow' funciton in Matlab2009a?

At school you have the student edition, which has many of the toolboxes.

At home, I do not know what license you have. What you need for imshow is the 
image processing toolkit. Perhaps you did not bother to install that at home, 
or perhaps you are not licensed for it.

imagesc() can replace imshow() calls in many cases; I've never seen any reason 
to use imshow() instead of image() or imagesc() myself.
0
Reply Walter 12/15/2010 12:17:28 AM

Walter Roberson <roberson@hushmail.com> wrote in message <ie91eq$sd1$1@nrc-news.nrc.ca>...
> On 10-12-14 05:52 PM, yan huang wrote:
> 
> > I can use the method at home, but cannot use in my school. In shcool, I use
> > Matlab R2009a that show error message ??? Undefined function or method
> > 'imshow' for input arguments of type 'char', while at home I use Matlab R2007
> > which have function 'imshow'.
> > Does any function replace 'imshow' funciton in Matlab2009a?
> 
> At school you have the student edition, which has many of the toolboxes.
> 
> At home, I do not know what license you have. What you need for imshow is the 
> image processing toolkit. Perhaps you did not bother to install that at home, 
> or perhaps you are not licensed for it.
> 
> imagesc() can replace imshow() calls in many cases; I've never seen any reason 
> to use imshow() instead of image() or imagesc() myself.

Hi, Walter
I am not sure how to use imagesc() to open a .bmp or .jpg file. From matlab help, it shows that I need load the file first. Does it mean that I have to save .bmp file in mat file format, then load it. Could you give me some details?

Thank you very much
0
Reply yan 12/15/2010 12:52:06 AM

yan huang:
here's some sample code for you.  The problem with image and imagesc
is that they apply some weird colormap by default when all you wanted
was to see the grayscale image.  To get around that, set the colormap
to gray with the colormap() function, or else use imshow().

Change the folder variable to the folder where you have your demo
images.

clc;    % Clear the command window.
close all;  % Close all figures (except those of imtool.)
imtool close all;  % Close all imtool figures.
clear;  % Erase all existing variables.
workspace;  % Make sure the workspace panel is showing.
fontSize = 20;

% Read in a standard MATLAB gray scale demo image.
folder = 'C:\Program Files\MATLAB\R2010a\toolbox\images\imdemos';
baseFileName = 'cameraman.tif';
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
	errorMessage = sprintf('Error: %s does not exist.', fullFileName);
	uiwait(warndlg(errorMessage));
	return;
end
grayImage = imread(fullFileName);
% Get the dimensions of the image.  numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);
% Display the original gray scale image.
image(grayImage);
% Apply gray colormap or else you'll get weird unexpected colors.
colormap(gray(256));
title('Original Grayscale Image', 'FontSize', fontSize);
1
Reply ImageAnalyst 12/15/2010 1:26:52 AM

On 10-12-14 06:52 PM, yan huang wrote:

> I am not sure how to use imagesc() to open a .bmp or .jpg file. From matlab
> help, it shows that I need load the file first. Does it mean that I have to
> save .bmp file in mat file format, then load it. Could you give me some details?

imagesc(imread('File.jpg'))

0
Reply Walter 12/16/2010 7:06:12 PM

7 Replies
1892 Views

(page loaded in 0.077 seconds)

Similiar Articles:













7/21/2012 6:41:18 PM


Reply: