Solved

Display Image in MATLAB GUI

Posted on 2001-06-11
12
9,417 Views
Last Modified: 2007-12-19
I created a GUI using the "guide" tool with MATLAB 6. How do I display an image within the GUI? Thanks.
0
Comment
Question by:streaks619
  • 7
  • 4
12 Comments
 
LVL 4

Expert Comment

by:prashant_n_mhatre
ID: 6178796
I know the answer. Let someone try out. I see many 'C' grades on your record.
0
 

Author Comment

by:streaks619
ID: 6190520
So - anybody have an answer?
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 6190797
Nope! Sorry...have never used Matlab....

Max.
0
 
LVL 4

Expert Comment

by:prashant_n_mhatre
ID: 6193956
OK...no one has answered this question till date. You might have figured out solution by this time. If not..try out these things...

You didn't mention whether you want image to be displayed at the start of the GUI program or after button press or mouse click on GUI.

In both cases the answer is same but with little variation.
I'm using MATLAB Version 5.3.0.10183.

(1) Display image on GUI as soon as GUI starts:

Then Better start GUI with image loading.

Use 'imread' and 'image' commands. See MATLAB help for options. The simplest way is:
at MATLAB prompt enter

a=imread('pnm.jpg');
image(a);

It will display image on figure. Then you invoke 'guide' and use mouse to adjust size. (figure must be in 'Controlled Mode'. Then save figure. Do whatever GUI stuff you want to do.


(2) Display image on GUI after button press.

'Add axes' from guide. Resize it as you wish. Add Button. Change caption using 'Property Editor' (String property). Selecting the button in figure - Use 'Callback Editor' from Guide. Select the appropriate action and add this code as a callback code.

a=imread('pnm1.jpg');
image(a);

To display image on mouse click you may select 'ButtonDownFcn'.

Feel free to get back to me if you have any doubt.

Best Regards,
PRASHANT.
0
 

Author Comment

by:streaks619
ID: 6194874
Let me give you the background for what I am doing -

I am creating a tracking program, where I am capturing consecutive video frames from a camera and then finding and following the moving people in the image.

I would like a GUI with two images: One is the original video frame. The second is a modified image with the individuals being tracked by some sort of dot or pointer.

Thus, each image needs to be constantly updated as more streaming data is processed.

0
 
LVL 4

Expert Comment

by:prashant_n_mhatre
ID: 6195152
What is the format of image?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:prashant_n_mhatre
ID: 6198265
streaks619  

I have already answered your original question. For the subsequent questions you are not providing me the additional information.

I'm not much familiar with video formats. You could have provided me the information and I would have tried it today. (Today is a holiday)

OK..all the very best...
0
 

Author Comment

by:streaks619
ID: 6198435
The format of the image can be anything I want it to be. The movie is in avi format, but the individual frames are just matrices of either (h x w) for black and white, or (h x w x 3) for color images.
0
 
LVL 4

Expert Comment

by:prashant_n_mhatre
ID: 6204329
Then images should not be a problem. Matlab supports many formats. Updating GUIs?...You can get handle of the original figure so You can use that handle.

Movies...ummn...
MATLAB comes with its own movie commands..Matlab's movies can only be played with MATLAB, they are generated slowly and consume enormous amounts of disk space when saved.

Does it support "avi" ? I have no idea. I do not have the latest version of MATLAB. Earlier version supports 'mpeg' and gif. (like animated gifs- using sequence of gifs)

0
 
LVL 4

Accepted Solution

by:
prashant_n_mhatre earned 200 total points
ID: 6208270
The command "lookfor avi" in my MATLAB yields the following functions:
AVIFINFO Text description of AVI-file contents.
AVIINFO Information about AVI file
AVIREAD Read AVI file.
movie2avi.m: %MOVIE2AVI(MOV,FILENAME) Create AVI movie from MATLAB movie
ADDFRAME  Add video frame to AVI file.
AVIFILE Create a new AVI file
CLOSE Finish writing and close AVI file.
DISPLAY Displays the AVIFILE object
GET Query AVIFILE properties
HORZCAT Horizontal concatenation of AVIFILE objects (disallowed)
SET Set properties of AVIFILE objects.
SUBSASGN subsasgn for an avifile object
SUBSREF subsref for a AVIFILE object
VERTCAT Vertical concatenation of AVIFILE objects (disallowed)
FINDCHUNK find chunk in AVI
FINDLIST find LIST in AVI
READAVI read frames from AVI file
SKIPCHUNK skip chunk in AVI
AVI write AVI file

It appears that there are plenty of functions that work with AVI files.  
0
 
LVL 4

Expert Comment

by:prashant_n_mhatre
ID: 6229143
any updates?
0
 

Author Comment

by:streaks619
ID: 7358298
I don't think any of this helped, but I'm gonna give you the points for trying...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fibonacci challenge 11 110
array11 challenge 16 61
Magic Software info 18 125
How to remove numeric and alpha from an alphanumeric field? 5 72
This is about my first experience with programming Arduino.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now