-1

I am working on pattern recognition project and currently in GUI creation phase. I would like to have a pushbutton that is able to perform the following command once the pushbutton is clicked:

a = imread(image_name);
b = rgb2gray(a);
glcm = graycomatrix(b);
glcm (:); 

May I know what function should I use to program the pushbutton? Your help is greatly appreciated.

Thank you.

wan
  • 141
  • 2
  • 3
  • 11

1 Answers1

4

Seems to me like you don't know how to make callback functions. Here's how to do it if you're building your GUI programmatically:

% create the button
but = uicontrol(...
    'style', 'pushbutton', ...
    'string', 'my awesome button',...
    'callback', @buttonCallback);  % <--- SET CALLBACK HERE

function buttonCallback(~,~)  % <--- what's called back when pressing the button
    a = imread(image_name);
    b = rgb2gray(a);
    glcm = graycomatrix(b);
    glcm (:); 
end

How to do it via GUIDE is similar, and outlined in detail here.

Rody Oldenhuis
  • 37,726
  • 7
  • 50
  • 96