How to have image as input for user defined function?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Anonymous
le 11 Mai 2018
Réponse apportée : Ameer Hamza
le 11 Mai 2018
I am trying to make a user defined function that will segment any image. I need my user defined function to have the input be the file name in single quotes. For example, if my user defined function is called read with my image as cells.tiff, I want the user to be able to do this: read('cells.tiff') and then have it analyze my image. How do I set my input variable in my user defined function and then have it save the image that the user typed as some variable to do the rest of my segmentation?
Réponse acceptée
Ameer Hamza
le 11 Mai 2018
Just take the filename as an input variable and use imread() to read the image. Here is a general template of your function
function segmentedImage = read(filename)
assert(exist(filename)~=0, sprintf('%s does not exist', filename));
image = imread(filename);
% do segmentation on variable image
segmentedImage = ... % assign your segmented image.
end
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!