MATLAB Answers

Need some help with the MatLab GUI

9 ビュー (過去 30 日間)
Ash 2011 年 12 月 25 日
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 ;)

  0 件のコメント


回答 (3 件)

Naz 2011 年 12 月 25 日
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 件のコメント

Ash 2011 年 12 月 26 日
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 2011 年 12 月 26 日
see updated. Ask if you have more questions.


Image Analyst
Image Analyst 2011 年 12 月 26 日
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:

  6 件のコメント

表示 3 件の古いコメント
Image Analyst
Image Analyst 2011 年 12 月 27 日
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 2011 年 12 月 27 日
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 2011 年 12 月 27 日


Ash 2011 年 12 月 26 日
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 件のコメント

Image Analyst
Image Analyst 2011 年 12 月 26 日
OK. Doesn't look too bad. Maybe a couple of hours of work or so... at least for me ;-)



Community Treasure Hunt

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

Start Hunting!

Translated by