Help Understanding groundTruth for CNN segmentation.
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Anshika Chaurasia
2021-9-17
编辑:Anshika Chaurasia
2021-9-17
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 个评论
yanqi liu
2021-9-28
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image and Video Ground Truth Labeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!