inp=b
DatasetPath=fullfile('C:\Users\Desktop\to');
imds=imageDatastore(DatasetPath, 'IncludeSubfolders', true,...
'LabelSource','foldernames','fileextension',{'.dcm'});
labelDir = fullfile(DatasetPath,'testImages');
I = readimage(imds,1);
I = histeq(I);
imshow(I)
classes = [
"MALIGNANT","BENIGN"
];
labelIDs=[255 0]
inputlayer = imageInputLayer([512 512 1],'Name','inp')
numFilters = 64;
numLayers = 16;
layers = [ ...
imageInputLayer([512 512 1])
convolution2dLayer(5,20)
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(5,20)
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
transposedConv2dLayer(4,numFilters,'Stride',2,'Cropping',1);
convolution2dLayer(5,20)
batchNormalizationLayer
reluLayer
transposedConv2dLayer(4,numFilters,'Stride',2,'Cropping',1);
convolution2dLayer(5,20)
batchNormalizationLayer
reluLayer
convolution2dLayer(5,20)
fullyConnectedLayer(4)
softmaxLayer
pixelClassificationLayer
]
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.01, ...
'MaxEpochs',1, ...
'Shuffle','every-epoch', ...
'ValidationFrequency',30, ...
'Verbose',false);
net=trainNetwork(imds,layers,options);
res = activations(net,inp,net.Layers(numLayers-1).Name,'OutputAs','channels');
I = read(imds);
C = semanticseg(I, net);
B = labeloverlay(I, C);
figure(12)
imshow(B)