フィルターのクリア

How to save and import gTruth objects

5 ビュー (過去 30 日間)
Max Salter
Max Salter 2022 年 12 月 4 日
コメント済み: Max Salter 2022 年 12 月 4 日
This seems like a simple problem, but I am trying to save a labeled image as a gTruth object from the Image Labeler. I can export from the Image Labeler to the workspace as a gTruth, but I would like to be able to load it programatically rather than manually importing to the workspace each time. When I save the gTruth variable from my workspave and load it in later, it loads as a struct, which does not work with pixelLabelTrainingData. How do I save a gTruth and have it load back as a gTruth?
% Porcelain_gTruth exists as a gTruth in the workspace from Image Labeler
save('Porcelain_gTruth.mat','Porcelain_gTruth')
% Later on
gTruth = load('Porcelain_gTruth.mat','Porcelain_gTruth');
% Now gTruth is a struct
[imds, pxds] = pixelLabelTrainingData(gTruth);
% I will get an error along the lines of:
% Error using pixelLabelTrainingData>parseInputs
% The value of 'gTruth' is invalid. Expected input to be one of these types:
%
% groundTruth
%
% Instead its type was struct.
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 12 月 4 日
Please show us
class(Porcelain_gTruth)
whos -file Porcelain_gTruth.mat

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

採用された回答

Walter Roberson
Walter Roberson 2022 年 12 月 4 日
gTruth = load('Porcelain_gTruth.mat','Porcelain_gTruth');
That form of load() does not return just the variable you asked to load. That form of load() returns a struct with one field for each variable that is loaded. You need something like
data = load('Porcelain_gTruth.mat','Porcelain_gTruth');
gTruth = data.Porcelain_gTruth;
  1 件のコメント
Max Salter
Max Salter 2022 年 12 月 4 日
Thank you so much!

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

その他の回答 (0 件)

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by