This problem related to Image processing and Deep learning using matlab.io.datastore.PixelLabelDatastor
Afficher commentaires plus anciens
In fact, I'm trying to download the spectrogram images (as input data, collected in a folder) and their labels for each pixel (collected in another folder). This work is to train a deep learning model.
after compilation, an error is displayed.
the code:
clear
clc
imds = imageDatastore('....data\trainingSet\input','IncludeSubfolders',false,'FileExtensions','.png');
classNames = ["NR" "LTE" "Noise"];
pixelLabelID = [127 255 0];
pxdsTruth = pixelLabelDatastore('....\data\trainingSet\label',classNames,pixelLabelID,...
'IncludeSubfolders',false,'FileExtensions','.png');
tbl = countEachLabel(pxdsTruth);
frequency = tbl.PixelCount/sum(tbl.PixelCount);
figure
bar(1:numel(classNames),frequency)
grid on
xticks(1:numel(classNames))
xticklabels(tbl.Name)
xtickangle(45)
ylabel('Frequency')
[imdsTrain,pxdsTrain,imdsVal,pxdsVal] = helperSpecSensePartitionData(imds,pxdsTruth,[80 20]);
cdsTrain = combine(imdsTrain,pxdsTrain);
cdsVal = combine(imdsVal,pxdsVal);
imageSize = [256 256];
cdsTrain = transform(cdsTrain, @(data)preprocessTrainingData(data,imageSize));
cdsVal = transform(cdsVal, @(data)preprocessTrainingData(data,imageSize));
The Errror:
Error using matlab.io.datastore.PixelLabelDatastore/subset
Cannot access method 'subset' in class 'matlab.io.datastore.PixelLabelDatastore'.
Error in helperSpecSensePartitionData (line 25)
pxdsTrain = subset(pxds, shuffledIndices(1:numTrain));
Error in mainProgramSRNet (line 25)
[imdsTrain,pxdsTrain,imdsVal,pxdsVal] = helperSpecSensePartitionData(imds,pxdsTruth,[80 20]);
3 commentaires
Pramil
le 29 Juil 2025
As per the error message, it seems MATLAB is not able to access the subset function, can you try the following command:
- which -all subset
The above should give you path to "ImageDatastore.m".
You can also try running MATLAB with administrative access, which you can do by searching MATLAB in windows search and right-clicking, then selecting "Run as administrator" to see if MATLAB is able to access the file then.
Chaymae
le 30 Juil 2025
Anjaneyulu Bairi
le 31 Juil 2025
Run the command "which -all subset", in your MATLAB Command Window.
Réponses (1)
Aryan
le 6 Août 2025
0 votes
Hi!
I understand that you are running into an error with the "subset" method in your code.
The issue is because the "subset" method for "PixelLabelDatastore" only exists in MATLAB R2021a and newer. If you are using an older version, that function just isn’t available.
Kindly refer to the following MathWorks documentation links for better understanding the functions used above:
Hope it helps!
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!