Need some help with the MatLab GUI

Hello,
I've an assignment and I need some help.
I'm trying to design a GUI that includes three buttons for three different compressing algorithms, and I need to import some test images from the GUI, I already have the algorithms written in Matlab (m-files), but how can I link the function with the button and how can I import an image and then compress it and preview it there; when I import an image it becomes two different matrices, one is the cdata and the other one is the colormap, i know i've to run the algorithms on the cdata, but how can i see the result
Sorry, I know I posted a long question but I need some help
Thanks ;)

Respuestas (3)

Naz
Naz el 25 de Dic. de 2011

0 votos

Since you already have your algorithms written, just create a new GUI and drug three buttons and one axis on the form. Automatically created .m file will contain all the code necessary to run the GUI. By clicking on each button in the gui editor, the callback functions (in the .m file) will be created for each respectively. Just paste your algorithm scripts into each corresponding callback function.
I don't completely understand your question. Assuming your algorithms are working, just put the code of each algorithm in the corresponding callback function. Since each algorithm will import the image, you dont really need to pass any parameters between other functions. Essential parameters such as handles are passed to the callback functions automatically: function pushbutton_callback(Object, handles...) or something like that. All necessary variables will be created within the callback function and dont need to be used outside that function (unless you are writing something more complicated). Of course, it is not the best way to write a program because every time you press a button the script will have to import the image, however it would be a good start to make sure each part of the script works properly. Later, you could create a separate function that will import the image, which could be used by all three algorithms instead of importing it three times. You could write this function in the main text or create another callback fucntion for a button that will be used to import image(s). In this case, your 'global' variables such as image data must be stored as handles.Yourvariable.

2 comentarios

Ash
Ash el 26 de Dic. de 2011
first of all; Thanks for the great help.
My test image probably will be the famous Lena512.bmp, I think I don't have to import another images, so I read about the idea that i have to import it through the OpeningFnc, but the algorithms need some parameters passing, i should pass it through the handles right?
Thanks again and please just give me the best idea to do this :)
Naz
Naz el 26 de Dic. de 2011
see updated. Ask if you have more questions.

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 26 de Dic. de 2011

0 votos

Ash, you aren't "importing images from the GUI," you're reading images from the disk. So simply use imread to read your lena image in from disk to a variable in your program, then use imshow to display it in the current axes. If you want, you can see many examples of this in my tutorials/demos in my File Exchange:
<a>www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862</a>

6 comentarios

Ash
Ash el 26 de Dic. de 2011
Thank you :)
My GUI contains two axes, I did imshow and the image displayed at axes2, my GUI should contain the image before compression is applied and after applying the compression, so how can I imshow the image at axes1 and the compressed image at axes2 ?
With JPEG compression, I should read the quality ratio from the user and pass it to the JPEG algorithm, I need a text box, how can i read the data from it ?
Sorry guys, I've one day left and they gave as the assignment from scratch, it's my first time using MatLab :(
Thank you all for the great help
Image Analyst
Image Analyst el 26 de Dic. de 2011
axes(axes1);
imshow(originalImage);
axes(axes2);
imshow(imageAfterCoDec);
Ash
Ash el 27 de Dic. de 2011
I had an error dialog saying: Error while attempting to activate figure. Undefined function or variable axes1.??
and for the test box how can i read a number ??
Image Analyst
Image Analyst el 27 de Dic. de 2011
Well obviously you have to pass in the actual name of the axes control that you are using. Maybe it's not axes1, but it's *something*! Just put in your actual names.
Ash
Ash el 27 de Dic. de 2011
hmm, no it's axes1 :) but i fixed it, i don't have to show both images;
By the way, does it matter if i'm using MatLab 7 ?
for the edit box, i should use get(hObject,'String'), I found it in the hint section, but how can i print something in the text box? i tried num2str(set(hObject,'String',MyValue)) ?
Walter Roberson
Walter Roberson el 27 de Dic. de 2011
set(hObject,'String',num2str(MyValue))

Iniciar sesión para comentar.

Ash
Ash el 26 de Dic. de 2011

0 votos

For you to have a look at the idea, i'm pasting the objectives: I've one of the two followings: 1-This assignment is to explore the median cut algorithm and color lookup tables (LUTs). The techniques that you will learn is the ability to read a color image (24 bits/pixel), manipulate the R, G, B data and display the resulting image on your computer screen. By the end of this assignment, you should be familiar with some basic image processing approaches using Matlab. 2-Please design a Graphical User Interface (GUI) to implement data compression algorithms in MATLAB.. These algorithms are divided into two main categories: · Lossless Compression (RLE ,Huffman ,LZW, Arithmetic coding) · Lossy Compression (JPEG) For lossy algorithms, find also Compression Performance (quality) using the following distortion measurements: MSE, SNR, PSNR Please test the JPEG scheme with different quality factors on the same image to see the results (Compression ratio, distortion measurements, and the resulting image)
Seriously guys, from scratch and three days and we're preparing for our finals

1 comentario

Image Analyst
Image Analyst el 26 de Dic. de 2011
OK. Doesn't look too bad. Maybe a couple of hours of work or so... at least for me ;-)

Iniciar sesión para comentar.

Categorías

Más información sobre Large Files and Big Data en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Ash
el 25 de Dic. de 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by