フィルターのクリア

Save ROI Object and load it later again

34 ビュー (過去 30 日間)
SturmGhost
SturmGhost 2018 年 7 月 10 日
コメント済み: DGM 2021 年 11 月 3 日
I have several pictures where the User defines different ROI-Objects. The user can switch between the currently displayed picture (Only one image is displayed at a time). Now I want to store each ROI-Object corresponding to each picture and load them when the User comes back to the picture with the corresponding ROI-Object. To be clear: The (re)loaded ROI-Object needs to be still customizable.
I saved each handle to the corresponding ROI-Object but now I don't have a clue how to show the ROI-Object again. How can I do this?
  2 件のコメント
Adam
Adam 2018 年 7 月 10 日
What is an 'ROI-object'? An imroi or something else?
Image Analyst
Image Analyst 2021 年 10 月 29 日
@Adam, drawpolygon() returns a variable that they call roi but is actually a variable of the "polygon" class.
The old imroi class from the Image Processing Toolbox is not recommended anymore, according to the help.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2018 年 7 月 10 日
Simply use save() to save your variable into a .mat file
save('roi.mat', 'yourROIVariable');
To recall:
s = load('roi.mat');
yourROIVariable = s.yourROIVariable;
  6 件のコメント
Nat
Nat 2021 年 11 月 3 日
編集済み: Nat 2021 年 11 月 3 日
When I try to save my ROI from drawellipse, it says it must be a text scalar. Here is my code. Do you know what to do?
Code:
file2Open = fullfile('LabeltheSkeleton.png');
image1 = imread('LabeltheSkeleton.png');
leftClavicleROI = drawellipse('Position', [100, 300]);
save('leftClavicleROI.mat', leftClavicleROI);
variable1 = load('leftClavicleROI.mat');
Error Message:
Error using save
Must be a text scalar.
Error in TestingFinalProjectParts (line 14)
save('leftClavicleROI.mat', leftClavicleROI);
DGM
DGM 2021 年 11 月 3 日
You need to pass the name of the variable, not the variable itself.
save('leftClavicleROI.mat', 'leftClavicleROI');

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by