Data transformation

Deterministic transformations.

Crop

layer eddl::Crop(layer parent, vector<int> from_coords, vector<int> to_coords, bool reshape = true, float constant = 0.0f, string name = "")

Crops the given image at [(top, left), (bottom, right)].

Parameters
  • parent – Parent layer

  • from_coords – Vector (top, left) coordinates

  • to_coords – Vector (bottom, right) coordinates

  • reshape – If True, the output shape will be new_shape (classical scale; recommended). If False, the output shape will be the input shape (scale<100%: scale + padding; scale >100%: crop + scale)

  • constant – Erasing value

  • name – A name for the operation

Returns

Output of crop transformation

Example:

l = Crop(l, {4,4},{24,24});

CenteredCrop

layer eddl::CenteredCrop(layer parent, vector<int> size, bool reshape = true, float constant = 0.0f, string name = "")

Crops the given image at the center with size (width, height).

Parameters
  • parent – Parent layer

  • size – Vector (height, width) size

  • reshape – If True, the output shape will be new_shape (classical scale; recommended). If False, the output shape will be the input shape (scale<100%: scale + padding; scale >100%: crop + scale)

  • constant – Erasing value

  • name – A name for the operation

Returns

Output of center crop transformation

Example:

l = CenteredCrop(l, {24,24});

CropScale

layer eddl::CropScale(layer parent, vector<int> from_coords, vector<int> to_coords, string da_mode = "constant", float constant = 0.0f, string name = "")

Crop the given image at [(top, left), (bottom, right)] and scale it to the parent size.

Parameters
  • parent – Parent layer

  • from_coords – Vector (top, left) coordinates

  • to_coords – Vector (bottom, right) coordinates

  • da_mode – One of “nearest”, “constant”, (ToDo: “mirror”, “reflect”, “wrap”, “original”)

  • constant – Fill value for area outside the rotated image, it is used for all channels respectively

  • name – A name for the operation

Returns

Output of crop scale transformation

Example:

l = CropScale(l, {8,8},{20,20});

Cutout

layer eddl::Cutout(layer parent, vector<int> from_coords, vector<int> to_coords, float constant = 0.0f, string name = "")

Selects a rectangle region in an image at [(top, left), (bottom, right)] and erases its pixels using a constant value.

Parameters
  • parent – Parent layer

  • from_coords – Vector (top, left) coordinates

  • to_coords – Vector (bottom, right) coordinates

  • constant – Erasing value

  • name – A name for the operation

Returns

Output of cutout transformation

Example:

l = Cutout(l, {0,0},{5,5});

Flip

layer eddl::Flip(layer parent, int axis = 0, string name = "")

Flip the given image at axis=n.

Parameters
  • parent – Parent layer

  • axis – Flip axis

  • name – A name for the operation

Returns

Output of flip transformation

Example:

l = Flip(l, 1);

HorizontalFlip

layer eddl::HorizontalFlip(layer parent, string name = "")

Horizontally flip the given image.

Parameters
  • parent – Parent layer

  • name – A name for the operation

Returns

Output of horizontal flip transformation

Example:

l = HorizontalFlip(l);

Pad

layer eddl::Pad(layer parent, vector<int> padding, float constant = 0.0f, string name = "")

Pad the given image on all sides with the given pad value.

Parameters
  • parent – Parent layer

  • padding – Padding on each border (top-bottom, left-right) or (top, right, bottom, left)

  • constant – pads with a constant value

  • name – A name for the operation

Returns

Padded image

l = Pad(l, {50, 50});

Rotate

layer eddl::Rotate(layer parent, float angle, vector<int> offset_center = {0, 0}, string da_mode = "original", float constant = 0.0f, string name = "")

Rotate the image by angle.

Parameters
  • parent – Parent layer

  • angle – In degrees counter clockwise order

  • offset_center – Optional center of rotation. Default is the center of the image

  • da_mode – One of “nearest”, “constant”, (ToDo: “mirror”, “reflect”, “wrap”, “original”)

  • constant – Fill value for area outside the rotated image, it is used for all channels respectively

Returns

Output of rotate transformation

Example:

l = Rotate(l, 30.0);

Scale

layer eddl::Scale(layer parent, vector<int> new_shape, bool reshape = true, string da_mode = "constant", float constant = 0.0f, string coordinate_transformation_mode = "asymmetric", string name = "")

Resize the input image to the given size. [height, width].

Parameters
  • parent – Parent layer

  • new_shape – Vector with layer/images desired new shape

  • reshape – If True, the output shape will be new_shape (classical scale; recommended). If False, the output shape will be the input shape (scale<100%: scale + padding; scale >100%: crop + scale)

  • da_mode – One of “nearest”, “constant”, (ToDo: “mirror”, “reflect”, “wrap”, “original”)

  • constant – Fill value for area outside the resized image, it is used for all channels respectively

  • coordinate_transformation_mode – This attribute describes how to transform the coordinate in the resized tensor to the coordinate in the original tensor.

Returns

Output of scale transformation

Example:

l = Scale(l, {35,35}, false);

Shift

layer eddl::Shift(layer parent, vector<int> shift, string da_mode = "nearest", float constant = 0.0f, string name = "")

Shift the input image [a, b].

Parameters
  • parent – Parent layer

  • shift – Vector of maximum absolute fraction for horizontal and vertical translations

  • da_mode – One of “nearest”, “constant”, (ToDo: “mirror”, “reflect”, “wrap”, “original”)

  • constant – Fill value for area outside the resized image, it is used for all channels respectively

Returns

Output of scale transformation

VerticalFlip

layer eddl::VerticalFlip(layer parent, string name = "")

Vertically flip the given image.

Parameters
  • parent – Parent layer

  • name – A name for the operation

Returns

Output of vertical flip transformation

Example:

l = VerticalFlip(l);