Labelled data from volume segmenter
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 27 Jul. 2022
'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
Antworten (1)
prabhat kumar sharma
am 26 Okt. 2023
Bearbeitet: prabhat kumar sharma
am 26 Okt. 2023
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 Kommentare
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!