Help Understanding groundTruth for CNN segmentation.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am attempting binary xray segementation using convolutional neural networks in matlab. I have a folder of the preoprocessed images, and a folder of binary segementations which match those images.
The segmentaions are binary so they have two class outputs denoted by a 0 and 1 respectively, "Background", "Cervical_Masks".
My problem stems from using the groundTruth function in matlab.
imds=imageDatastore('Stringtofiles', 'FileExtensions', '.tif', 'IncludeSubfolders', 0, 'LabelSource', 'foldernames');
imds_Masks=imageDatastore('/Stringtofiles', 'FileExtensions', '.tif', 'IncludeSubfolders', 0, 'LabelSource', 'foldernames');
groundT=groundTruthDataSource(imds);
ldc = labelDefinitionCreator();
addLabel(ldc,'Cervical_Masks',labelType.PixelLabel);
addLabel(ldc,'Background',labelType.PixelLabel, PixeWhenlLabelID.0);
labelDefs = create(ldc);
labelData=table(imds_Masks.Files, 'VariableNames', {'PixelLabelData'});
gTruth = groundTruth(groundT,labelDefs,labelData);
[imds,pxds] = pixelLabelTrainingData(gTruth);
After this point my data is wrong.
Simply checking it for any subject reveals that the pxds file which should represent the mask is incorrect.
subject=22
I = readimage(imds,subject);
C = readimage(pxds,subject);
imshowpair(I,uint8(C),'montage')
I think this is because I am not using the labeling correct.
Could someone please help?
Thanks!
0 comentarios
Respuestas (2)
Anshika Chaurasia
el 17 de Sept. de 2021
Editada: Anshika Chaurasia
el 17 de Sept. de 2021
Hi,
On looking the provided code, the possible reason for incorrect label could be in following line:
addLabel(ldc,'Background',labelType.PixelLabel, PixeWhenlLabelID.0);
I am not sure about "PixeWhenlLabelID.0".
It would be better if you can share the images or some test code. It would be easy for us to reproduce your issue at our end.
Refer to the following blog:
0 comentarios
yanqi liu
el 28 de Sept. de 2021
sir,please check the follow code to get some information
clc; clear all; close all;
% image file
data = load('stopSignsAndCars.mat');
imageFilenames = data.stopSignsAndCars.imageFilename(1:2)
imageFilenames = fullfile(toolboxdir('vision'),'visiondata',imageFilenames);
dataSource = groundTruthDataSource(imageFilenames);
% label
ldc = labelDefinitionCreator();
addLabel(ldc,'stopSign',labelType.Rectangle);
addLabel(ldc,'carRear',labelType.Rectangle);
labelDefs = create(ldc)
% add target
stopSignTruth = {[856 318 39 41];[445 523 52 54]};
carRearTruth = {[398 378 315 210];[332 633 691 287]};
% make label
labelNames = {'stopSign';'carRear'};
labelData = table(stopSignTruth,carRearTruth,'VariableNames',labelNames)
% display
gTruth = groundTruth(dataSource,labelDefs,labelData)
figure; imshow(gTruth.DataSource.Source{1});
hold on;
rectangle('Position', gTruth.LabelData.stopSign{1}, 'EdgeColor', 'g', 'LineWidth', 2);
rectangle('Position', gTruth.LabelData.carRear{1}, 'EdgeColor', 'c', 'LineWidth', 2);
0 comentarios
Ver también
Categorías
Más información sobre Image and Video Ground Truth Labeling en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!