Load image in App Designer
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone, I have a code to reconstruct image MRI. First I want to create a Select Image Button to select image from my computer and I create RUN Button to run my code with the image i selected. But I don't know how to get the image I choosed in Select Image Button To RUN Button. When I run it can not recognized the image.
Unrecognized function or variable 'image1'.

0 Commenti
Risposte (1)
Pratyush Swain
il 10 Ott 2023
Hi N,
I understand you pass the image obtained in the 'SelectImageButtonPushed' function to the 'RUNButtonPushed' function in App Designer.
To acheive this you will need to setup a new property in a user defined properties block.Please refer to https://in.mathworks.com/matlabcentral/answers/1829948-passing-objects-from-app-designer-to-the-workspace#comment_2749059 to create a basic property.
Assuming you have a made a property named 'image' , you can refer to the implementation below:
function SelectImageButtonPushed(app, event)
% Open a file dialog to select an image file
[file, path] = uigetfile({'*.jpg;*.png;*.bmp', 'Image Files (*.jpg, *.png, *.bmp)'}, 'Select Image File');
% Read the selected image
image = imread(fullfile(path, file));
% Store the image in the app object as a property
app.image = image;
end
% Run Button Callback
function RUNButtonPushed(app, event)
% Check if an image is selected
if isempty(app.image)
% Display an error message if no image is selected
errordlg('No image selected.', 'Error', 'modal');
return;
end
% Perform operations on the selected image
% Access the image using app.image
% Example:
processedImage = imresize(app.image, 0.5);
% Display the processed image or perform any other desired operations
imshow(processedImage, 'Parent', app.UIAxes);
end
Hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Convert Image Type in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!