I need to segment my input image using unet segmentation

7 次查看(过去 30 天)
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 个评论
SARAH LONER
SARAH LONER 2019-11-27
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?
Manjunath R V
Manjunath R V 2021-4-21
have u got solution for the above query sarah if so please share it

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2019-11-27
In the imageDatastore() function there is an option to specify the reader. For example, try something like:
imds = imageDatastore('*.dcm','ReadFcn',@dicomread);
  4 个评论
SARAH LONER
SARAH LONER 2019-11-29
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
Image Analyst
Image Analyst 2019-11-29
Sorry, I can't do that. If you need help, the Mathworks can help you. Contact them here: Mathworks Consulting

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by