I need to segment my input image using unet segmentation

where inp is my input image
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
]
% pxds = pixelLabelDatastore(labelDir,classes,labelIDs);
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 = read(pxds)
C = semanticseg(I, net);
% Overlay pixel label data on the image and display.
B = labeloverlay(I, C);
figure(12)
imshow(B)
I got error @
Error using trainNetwork
Not enough input arguments.
Error in
net=trainNetwork(imds,layers,options);I

2 commentaires

my input image was dicom image.
when i remove comment at pixelLabelDatastore it shows an eror that my
Input folders or files do not contain specified file extensions:
.bmp,.cur,.fts,.fits,.gif,.hdf,.ico,.j2c,.j2k,.jp2,.jpf,.jpx,.jpg,.jpeg,.pbm,.pcx,.pgm,.png,.pnm,.ppm,.ras,.tif,.tiff,.xwd
can any1 suggest me a solution for this?
have u got solution for the above query sarah if so please share it

Connectez-vous pour commenter.

 Réponse acceptée

In the imageDatastore() function there is an option to specify the reader. For example, try something like:
imds = imageDatastore('*.dcm','ReadFcn',@dicomread);

4 commentaires

it showing error
You're right. I guess that since it's not in the list given by imformats, it doesn't list them.
Try fileDatastore() instead:
imds = fileDatastore('*.dcm', 'ReadFcn', @dicomread)
fileNames = imds.Files
I tried it and that does retrieve the file names.
HAI SIR CAN U GUIDE ME ONCE AGAIN ON ANOTHER ERROR I CANT ABLE TO TRAIN IMAGE
i cant able to read image at pxds in above code and once i cleared that i cant able to train network at
net=trainNetwork(pxds,layers,options);
kindly guide me to solve this error
Sorry, I can't do that. If you need help, the Mathworks can help you. Contact them here: Mathworks Consulting

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by