Solved

Display Image in MATLAB GUI

Posted on 2001-06-11
12
9,397 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

759 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

20 Experts available now in Live!

Get 1:1 Help Now