can you segment with the 3D unet an image with unequal dimensions, like 128x384x128 for example as an input to the model?

13 次查看(过去 30 天)
I am using the unet 3d segmentation matlab built in function. tyoical inputs to that function is equal spaced dimentioons of 32, 64, 128, 256, and so on. can i input an image of size 128x384x128 to the unet function. if not then why?

回答(1 个)

Karl
Karl 2024-4-29
The function unet3d() doesn't require that images have the same size in each dimension. From the documentation for the input argument inputSize, it does have the constraint: "Network input image size must be chosen such that the dimension of the inputs to the max-pooling layers must be even numbers."
% Define number of classes.
numClasses = 5;
% This works - image sizes in all dimensions are integer multiples of 2^3.
unet1 = unet3d([128 384 128], numClasses, EncoderDepth=3)
unet1 =
dlnetwork with properties: Layers: [62x1 nnet.cnn.layer.Layer] Connections: [67x2 table] Learnables: [64x3 table] State: [28x3 table] InputNames: {'encoderImageInputLayer'} OutputNames: {'FinalNetworkSoftmax-Layer'} Initialized: 1 View summary with summary.
% This gives an error - 386 isn't an integer multiple of 2^2.
unet2 = unet3d([128 386 128], numClasses, EncoderDepth=2)
Error using unet3d>iValidateInputSize (line 150)
The width, height, and depth of the image must be a multiple of 2^EncoderDepth. You can specify image size as [128 384 128 1] instead of [128 386 128 1].

Error in unet3d (line 43)
iValidateInputSize(inputSize, encoderDepth, convolutionPadding, convFilterSize);

Community Treasure Hunt

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

Start Hunting!

Translated by