Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
can i use List box to show image?

Subject: can i use List box to show image?

From: Mohammad Zahid

Date: 7 Apr, 2011 18:00:31

Message: 1 of 7

Hello,

I have an 10 sample of image, and i want to use list box in GUI, so user can choose any of sample from 1 to 10 of image and see it on axes. I only know how to use Listbox for callback text and show it on static text, but how if i want to choose an sample image in Listbox to show on axes that i have set the handles, can it process to call the sample image?

Subject: can i use List box to show image?

From: ImageAnalyst

Date: 7 Apr, 2011 20:16:47

Message: 2 of 7

On Apr 7, 2:00 pm, "Mohammad Zahid" <souljack...@yahoo.com.my> wrote:
> Hello,
>
> I have an 10 sample of image, and i want to use list box in GUI, so user can choose any of sample from 1 to 10 of image and see it on axes.  I only know how to use Listbox for callback text and show it on static text, but how  if i want to choose an sample image in Listbox to show on axes that i have set the handles, can it process to call the sample image?
-----------------------------------------------------------------------------------------------------------------------------------
I don't believe so. You'd have to use Visual Studio to do anything
that fancy. Maybe you can do it in MATLAB if you place the
appropriate ActiveX control on your GUI, but you'd have to have that
control installed. I'm not even sure off the top of my head which
Visual Studio control it would be.

Subject: can i use List box to show image?

From: Mohammad Zahid

Date: 7 Apr, 2011 22:42:04

Message: 3 of 7

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <cd0cdb05-4bf6-47fc-a6eb-83c6b257e5cd@d12g2000vbz.googlegroups.com>...
> On Apr 7, 2:00 pm, "Mohammad Zahid" <souljack...@yahoo.com.my> wrote:
> > Hello,
> >
> > I have an 10 sample of image, and i want to use list box in GUI, so user can choose any of sample from 1 to 10 of image and see it on axes.  I only know how to use Listbox for callback text and show it on static text, but how  if i want to choose an sample image in Listbox to show on axes that i have set the handles, can it process to call the sample image?
> -----------------------------------------------------------------------------------------------------------------------------------
> I don't believe so. You'd have to use Visual Studio to do anything
> that fancy. Maybe you can do it in MATLAB if you place the
> appropriate ActiveX control on your GUI, but you'd have to have that
> control installed. I'm not even sure off the top of my head which
> Visual Studio control it would be.

 Ehm, i really need to list up the sample. How about pop-up menu, i have list up all 10 sample in the string properties. Then when user choose sample 1, image of sample 1 will show on axes. Are the coding same with display the text?

Subject: can i use List box to show image?

From: ImageAnalyst

Date: 7 Apr, 2011 23:51:37

Message: 4 of 7

I don't know what this means "list up the sample" or this: "list up
all 10 sample in the string properties"

The way I do it is to have all the filennames listed in a listbox and
then when the user clicks on one, it displays the image in a listbox.
Here is a nice framework for doing that - I suggest you 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.

Subject: can i use List box to show image?

From: Yair Altman

Date: 8 Apr, 2011 09:27:04

Message: 5 of 7

"Mohammad Zahid" <souljack_87@yahoo.com.my> wrote in message <inku3v$g8t$1@fred.mathworks.com>...
> Hello,
>
> I have an 10 sample of image, and i want to use list box in GUI, so user can choose any of sample from 1 to 10 of image and see it on axes. I only know how to use Listbox for callback text and show it on static text, but how if i want to choose an sample image in Listbox to show on axes that i have set the handles, can it process to call the sample image?

Displaying images in Matlab listboxes and editboxes is possible, but undocumented and unsupported. This can get you started: http://undocumentedmatlab.com/blog/rich-matlab-editbox-contents/

Yair Altman
http://UndocumentedMatlab.com

Subject: can i use List box to show image?

From: Mohammad Zahid

Date: 9 Apr, 2011 02:52:04

Message: 6 of 7

"Yair Altman" wrote in message <inmkd8$374$1@fred.mathworks.com>...
> "Mohammad Zahid" <souljack_87@yahoo.com.my> wrote in message <inku3v$g8t$1@fred.mathworks.com>...
> > Hello,
> >
> > I have an 10 sample of image, and i want to use list box in GUI, so user can choose any of sample from 1 to 10 of image and see it on axes. I only know how to use Listbox for callback text and show it on static text, but how if i want to choose an sample image in Listbox to show on axes that i have set the handles, can it process to call the sample image?
>
> Displaying images in Matlab listboxes and editboxes is possible, but undocumented and unsupported. This can get you started: http://undocumentedmatlab.com/blog/rich-matlab-editbox-contents/
>
> Yair Altman
> http://UndocumentedMatlab.com

Thank ImageAnalyst & Yair Altman for the suggestion.
I have try the simple way in showing image by using pop-up menu. By using case function, 1 image for each of case, the problem is when i choose image sample 1, the image that come out is image sample 2, an so on if i choose image sample 2, image 3 will show. why is this happen, because i have set the image. here is my code:

sample = get(handles.listsample,'value');
switch sample
    case 1
        S1=imread('sample_1.jpg');
        axes(handles.axesoriginal);
        imshow(S1);
    case 2
        S2=imread('sample_2.jpg');
        axes(handles.axesoriginal);
        imshow(S2);
    case 3
        S3=imread('sample_3.jpg');
        axes(handles.axesoriginal);
        imshow(S3);
end

Why the image that come out are not as i set?

Subject: can i use List box to show image?

From: ImageAnalyst

Date: 10 Apr, 2011 17:41:25

Message: 7 of 7

I don't know because the indexes are 1-based, not 0-based. This is
where you'd know what's going on if you knew how to set breakpoints,
examine variable values, and step the code. Maybe you can try an "if"
statement instead of a switch statement.

Anyway, this is the code I'd use. Note that I construct the full
filename and use fullfile(), exist(), sprintf(), and warndlg().

% Get the index of the selected item in the popup.
selectedItem = get(handles.listsample,'value');
% Get the name they chose.
switch selectedItem
    case 1
        baseFileName = 'sample_1.jpg';
    case 2
        baseFileName = 'sample_2.jpg';
    case 3
        baseFileName = 'sample_3.jpg';
end
% Construct the full filename.
folder = pwd;
fullFileName = fullfile(folder, baseFileName);
% Make sure it exists in that folder.
if exist(fullFileName, 'file')
% File exists so display it.
axes(handles.axesoriginal);
imshow(S1);
else
% File does not exist - warn user.
errorMessage = sprintf('Error:\n%s\ndoes not exist', fullFileName);
uiwait(warndlg(errorMessage));
end

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us