Hi,
So I'm trying to read the image and then pass it through a function so that I can perform image analysis with some defined parameters.
For the "Load Image" button here's the code:
% Button pushed function: LoadImageButton
function LoadImageButtonPushed(app, event)
[FileName, FilePath]= uigetfile('.TIF');
I=imread([FilePath FileName]);
imshow(I, 'Parent' , app.UIAxes); %Displays selected image onto original image
I would then need to define some paratmers (Filter Size, Threshold, Cut Cells Regions) before running my external function. Once you input the paramters and press "Compute", I'm hoping that it would go into my function that I've written (called trialfunction here):
function ComputeButtonPushed(app, event)
filter_size = app.FilterSizeEditField; %Input parameter
trialfunction(I_M,filter_size)
S = app.ValueEditField;
The "trial function" is just a simple range filter that manipulates the image (stored in a 2D matrix):
function[S]=trialfunction(I_M,filter_size);
I_bin_regions = rangefilt(I_M,ones(filter_size,filter_size));
S=sum(I_bin_regions,'all')
end
However, I'm having trouble linking the data from I (2D matrix) into my function. How can I "connect" the "Load Image" function with the "Compute Button" function?
Thanks so much!
Note: I have tried adding app.I.ImageSource = imread (...) but that doesn't work. Error message says "
Unrecognized method, property, or field 'I' for class 'imageprocessing'.
2 Comments
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/536911-matlab-gui-how-do-i-pass-image-matrix-into-function#comment_871703
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/536911-matlab-gui-how-do-i-pass-image-matrix-into-function#comment_871703
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/536911-matlab-gui-how-do-i-pass-image-matrix-into-function#comment_871719
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/536911-matlab-gui-how-do-i-pass-image-matrix-into-function#comment_871719
Sign in to comment.