Main Content


3-D crop layer

Since R2019b


A 3-D crop layer crops a 3-D volume to the size of the input feature map.

Specify the number of inputs to the layer when you create it. The inputs to the layer have the names 'in' and 'ref'. Use the input names when connecting or disconnecting the layer by using connectLayers or disconnectLayers. All inputs to a 3-D crop layer must have the same number of dimensions.



layer = crop3dLayer creates a 3-D crop layer that crops an input feature map from the center of the feature map. The size of the cropped region is equal to the size of a second reference input feature map.

layer = crop3dLayer([X Y Z]) also sets the cropLocation property with the (X,Y,Z) coordinate of the crop window. X is the coordinate in the horizontal direction, Y is the coordinate in the vertical direction, and Z is the coordinate in the depth direction.


layer = crop3dLayer(___,'Name',Name) also sets the Name property. To create a network containing a 3-D crop layer, you must specify a layer name.


expand all


Crop location, specified as 'centercrop' or a three-element numeric vector representing the (x,y,z) coordinate of the crop window.


Layer name, specified as a character vector or a string scalar. For Layer array input, the trainnet and dlnetwork functions automatically assign names to layers with the name "".

The Crop3DLayer object stores this property as a character vector.

Data Types: char | string

Number of inputs of the layer. This layer accepts two inputs.

Data Types: double

Input names of the layer, specified as {'in','ref'}. This layer accepts two inputs.

Data Types: cell

This property is read-only.

Number of outputs from the layer, returned as 1. This layer has a single output only.

Data Types: double

This property is read-only.

Output names, returned as {'out'}. This layer has a single output only.

Data Types: cell


collapse all

Create a 3-D crop layer.

layer = crop3dLayer
layer = 
  Crop3DLayer with properties:

            Name: ''
    CropLocation: 'centercrop'
       NumInputs: 2
      InputNames: {'in'  'ref'}

Create a neural network containing a 3-D crop layer.

net = dlnetwork;

layers = [
    image3dInputLayer([32 32 32 3],Name="image")

net = addLayers(net,layers);

Add a max pooling layer to the neural network.

layer = maxPooling3dLayer(2,Stride=2,Name="pool");
net = addLayers(net,layer);
net = connectLayers(net,"image","pool");

Connect the second input of the crop layer to the output of the max pooling layer.

net = connectLayers(net,"pool","crop/ref");

Concatenate the crop layer output and the max pooling layer output.

net = connectLayers(net,"pool","concat/in2");

Display the neural network in a plot.



expand all

Version History

Introduced in R2019b

expand all