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