How to write imageDatastore include labels.

8 vues (au cours des 30 derniers jours)
mohd akmal masud
mohd akmal masud le 23 Août 2022
Réponse apportée : David Ho le 24 Août 2022
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.

Réponse acceptée

David Ho
David Ho le 24 Août 2022
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:

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by