How to write imageDatastore include labels.

8 ビュー (過去 30 日間)
mohd akmal masud
mohd akmal masud 2022 年 8 月 23 日
回答済み: David Ho 2022 年 8 月 24 日
Hi all..
I have the original data (ImageTr as attached), and labels data (LabelsTr as attached) for training. My problems is how to write imageDatastore include labels in it?
Because the labels in LabelsTr folder
I try this one but was error.
clc
clear all
close all
%testDataimages
DATASetDir = fullfile('C:\Users\Akmal\Desktop\NEW 3D U NET');
IMAGEDir = fullfile(DATASetDir,'ImagesTr');
volReader = @(x) matRead(x);
volds = imageDatastore(IMAGEDir, ...
'FileExtensions','.mat','ReadFcn', volReader);
% labelReader = @(x) matread(x);
matFileDir = fullfile('C:\Users\Akmal\Desktop\NEW 3D U NET\LabelsTr');
classNames = ["background", "tumor"];
pixelLabelID = [0 1];
% pxds = (LabelDirr,classNames,pixelLabelID, ...
% 'FileExtensions','.mat','ReadFcn',labelReader);
pxds = pixelLabelDatastore(matFileDir,classNames,pixelLabelID, ...
'FileExtensions','.mat','ReadFcn',@matRead);
p = imageDatastore(volds,pxds);
ERROR
Error using imageDatastore
Expected a string scalar or character vector for the parameter name.

採用された回答

David Ho
David Ho 2022 年 8 月 24 日
To combine the two datastores into a single datastore, one option would be to use the combine function to create a CombinedDatastore:
cds = combine(volds, pxds);
Alternatively, if you wish to use the datastore for semantic segmentation, you might find a randomPatchExtractionDatastore to be the most useful:
patchSize = [50 50 50];
patchds = randomPatchExtractionDatastore(volds, pxds, patchSize);
This extracts corresponding randomly-positioned patches from the two datastores.
For a complete example showing how to perform semantic segmentation of 3-D volumes using deep learning, you can take a look at this example:

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by