pixelLabelDatastore only supports pixel label image files with uint8 data
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have built a Segnet (deep learning network) for tumor segmentation. My images are stored in 3D form with extension (.nii) i.e. medical file named NIFTI (Neuro imaging) file. each .nii file contains varying no of slices from 40 to 1200.
Can you please help me to clear this error?
Error using trainNetwork (line 165)
By default, pixelLabelDatastore only supports pixel label image files with uint8 data.
Use ReadFcn to specify a custom read function that returns categorical labels from non-uint8 image data.
4 commentaires
Walter Roberson
le 3 Juil 2022
Which of the three possibilities I described matches for you? https://www.mathworks.com/matlabcentral/answers/490601-pixellabeldatastore-only-supports-pixel-label-image-files-with-uint8-data#answer_408483
Réponses (2)
Walter Roberson
le 3 Jan 2020
There are three possibilities in this situation:
1)
If the image input file happens to not be uint8, but there are at most 256 different unique input values and each of them represents a different class, then construct a mapping list of the expected unique input values:
value_list = [17, 83:89, 293:295]; %the unique values that occur
Then have a custom ReadFcn that does:
InputImage = imread(filename);
[~, idx] = ismember(InputImage, value_list);
LabelOutput = uint8(idx-1);
2)
If the image input file happens to not be uint8, and there are more than 256 different unique input values, but multiple input values correspond to the same class, so there are at most 256 different classes, then construct a two-part mapping list:
value_list = [17, 83 84 84 86 87 88 89, 293 294 295]; %the unique values that occur
classnums = [1, 2 2 2 3 4 4 4, 5 6 6]; %corresponding class numbers
and have a custom ReadFcn that does
InputImage = imread(filename);
[~, idx] = ismember(InputImage, value_list);
LabelOutput = uint8(classnums(idx));
3)
If the image input file happens to not be uint8, and there are more than 256 different classes, then use the technique shown in https://www.mathworks.com/help/matlab/ref/categorical.html#bt0w4ft-4 "Specify category names for integers" to construct a categorical array corresponding to the inputs. If you want multiple input values to correspond to the same category then you can list the same category name multiple times. For example,
>> A = categorical(1:10, [1;2;3;4;10],{'one', 'two', 'three', 'three', 'three'}), uint16(A)
A =
1×10 categorical array
one two three three <undefined> <undefined> <undefined> <undefined> <undefined> three
ans =
1×10 uint16 row vector
1 2 3 3 0 0 0 0 0 3
0 commentaires
Gökay Karayegen
le 24 Mai 2020
Hello how can I fix the following error. Please help me to solve this problem ?
classNames = ["background","edema","nonEnhancingTumor","enhancingTumour"];
labelIDs = [0 1 2 3];
dinfo = dir(fullfile(labelDir, '**', '*.nii'));
filenames = fullfile({dinfo.folder}, {dinfo.name});
pxds = pixelLabelDatastore(filenames,classNames,labelIDs);
pxds.ReadFcn = matReader;
ERROR
.bmp,.cur,.fts,.fits,.gif,.hdf,.ico,.j2c,.j2k,.jp2,.jpf,.jpx,.jpg,.jpeg,.pbm,.pcx,.pgm,.png,.pnm,.ppm,.ras,.tif,.tiff,.xwd
Error in pixelLabelDatastore (line 152)
ds = matlab.io.datastore.PixelLabelDatastore.create(location, classes, values, params);
Error in semantik_derinogrenme (line 118)
pxds = pixelLabelDatastore(filenames,classNames,labelIDs);
1 commentaire
Walter Roberson
le 24 Mai 2020
Modifié(e) : Walter Roberson
le 24 Mai 2020
You seem to have left out the first line or two of the error message? Was it saying that only the given file types were accepted?
Ah, I see you posted the whole message over at https://www.mathworks.com/matlabcentral/answers/488024-input-folders-or-files-do-not-contain-specified-file-extensions#comment_849845 which is probably a better place to have the conversation.
Voir également
Catégories
En savoir plus sur Get Started with Statistics and Machine Learning Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!