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 で Image Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!