Labelled data from volume segmenter
조회 수: 4 (최근 30일)
이전 댓글 표시
I have a 3D data 461by951by651 as a mat file and I used the volume segmenter app to label it. I got a 3D categorical Label of the same size as the data. I can not use this label as an input for a data store or for a training network as it has to be in an array. I tried using reshape function but it didn’t work. Any help?
댓글 수: 3
Walter Roberson
2022년 7월 27일
'Labels' as a property is expected to be the actual label content. There is no direct way to specify a corresponding file name, not that I can see.
You can set the Labels property, but you cannot do so on a per-file basis.
When you use imageDatastore, then the label is expected to be the label for the entire image.
Perhaps you should be using Ground Truth techniques; https://www.mathworks.com/help/vision/ref/groundtruth.html and https://www.mathworks.com/discovery/ground-truth.html
답변 (1개)
prabhat kumar sharma
2023년 10월 26일
편집: prabhat kumar sharma
2023년 10월 26일
Hello Amen,
I understand you are facing issue with the labels of the data. As you are using 2D CNN then you have to convert your 3D MAT file data into 2D. When you convert your 3D data into 2D slices and treat each slice as an independent sample, you will need to have a label for each slice.
Typically, labels are 1D where each element in the array corresponds to a label for the corresponding sample in your dataset. For instance, if you have 1000 samples, you need to have a 1D array of 1000 labels.
If you convert your 3D data into 2D slices, the number of samples in your dataset will increase (since each slice is now a separate sample), and you will need to create a label for each slice.
So, if you originally had a 3D matrix with dimensions 461x951x651 and you convert this into 2D slices, you will have 651 slices (assuming you're slicing along the third dimension). You will then need a 1D array of 651 labels - one for each slice.
Remember that the order of the labels should match the order of the slices. The first label in your array corresponds to the first slice, the second label to the second slice, and so on.
You can refer the below code for conversion of labels.
% Assuming your 3D label matrix is stored in the variable 'labels3D'
labels3D = load('F3\Labels'); % Adjust this line according to how you're loading your labels
% Convert the 3D label matrix to 2D slices
labels2D = squeeze(mat2cell(labels3D, size(labels3D, 1), size(labels3D, 2), ones(1, size(labels3D, 3))));
% Now, you need to assign a single label for each 2D slice. This depends on your specific task.
% If you're doing classification and each slice belongs to a single class, you might take the most common label in each slice:
labels = cellfun(@(x) mode(x(:)), labels2D);
I hope it helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 AI for Signals에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!