MATLAB Answers


Creating a dialog box menu for the imread function.

Asked by Edvardas
on 16 Apr 2013


Currently I am finishing an image analyzing script the reads graphs from a .jpg image file. One of the things I did is make it viable to use for various sizes of image files for different graphs, however I am stuck on implementing a menu through which I could choose an image file which then would be read via the imread function, and then the data would be used throughout the script.

Ideally what I'm thinking of is something of the form of this (I realize that this particular option can only be run when using Load function, I think, I just put it as an example of what I'm aiming towards), tp is the matrix for the image file:

    if menu == 1
    elseif menu == 2
    elseif menu == 3
    elseif menu == 4
    elseif menu == 5
    elseif menu == 6
    elseif menu == 7
    elseif menu == 8
        tp = imread('temp850.jpg');
    menu = menu('title', 'Tile 468', 'Tile 480', 'Tile 502', 'Tile 590', 'Tile 597', 'Tile 711', 'Tile 730', 'Tile 850');

If someone would have a suggestion of what could be done to get a pop up menu which would allow the selection of what image file to read I would be very grateful.

Thank you for your time.




1 Answer

Answer by Image Analyst
on 16 Apr 2013
 Accepted answer

Don't use menu for both the function and it's return argument. Also, the call to menu() must come before you call imread() so that you know what image to read in.

  1 Comment

Oh, kind of an embarrassing mistake then.

Thank you for pointing out, everything works as expected now!



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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!