How to have image as input for user defined function?
2 ビュー (過去 30 日間)
古いコメントを表示
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?
採用された回答
Ameer Hamza
2018 年 5 月 11 日
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!