pixelLabelDatastore only supports pixel label image files with uint8 data

조회 수: 6 (최근 30일)
Emerson Nithiyaraj
Emerson Nithiyaraj 2019년 11월 12일
댓글: Walter Roberson 2022년 7월 3일
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
quino
quino 2022년 7월 3일
Excuse me,have you solved this problem?
Walter Roberson
Walter Roberson 2022년 7월 3일
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

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2020년 1월 3일
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

Gökay Karayegen
Gökay Karayegen 2020년 5월 24일
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
Walter Roberson
Walter Roberson 2020년 5월 24일
편집: Walter Roberson 2020년 5월 24일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by