Main Content

translate

Translate structuring element

Description

SE2 = translate(SE,v) translates the structuring element SE in N-D space. v is an N-element vector containing the offsets of the desired translation in each dimension.

example

Examples

collapse all

Read an image into the workspace.

I = imread('cameraman.tif');

Create a structuring element and translate it down and to the right by 25 pixels.

se = translate(strel(1), [25 25]);

Dilate the image using the translated structuring element.

J = imdilate(I,se);

Display the original image and the translated image.

figure
imshow(I), title('Original')

Figure contains an axes object. The hidden axes object with title Original contains an object of type image.

figure
imshow(J), title('Translated');

Figure contains an axes object. The hidden axes object with title Translated contains an object of type image.

Create an offset structuring element.

SE = offsetstrel('ball', 5, 6.5)
SE = 
offsetstrel is a ball shaped offset structuring element with properties:

            Offset: [11x11 double]
    Dimensionality: 2

SE.Offset
ans = 11×11

      -Inf      -Inf         0    0.8123    1.6246    2.4369    1.6246    0.8123         0      -Inf      -Inf
      -Inf    0.8123    1.6246    2.4369    3.2492    3.2492    3.2492    2.4369    1.6246    0.8123      -Inf
         0    1.6246    2.4369    3.2492    4.0615    4.0615    4.0615    3.2492    2.4369    1.6246         0
    0.8123    2.4369    3.2492    4.0615    4.8738    4.8738    4.8738    4.0615    3.2492    2.4369    0.8123
    1.6246    3.2492    4.0615    4.8738    5.6861    5.6861    5.6861    4.8738    4.0615    3.2492    1.6246
    2.4369    3.2492    4.0615    4.8738    5.6861    6.4984    5.6861    4.8738    4.0615    3.2492    2.4369
    1.6246    3.2492    4.0615    4.8738    5.6861    5.6861    5.6861    4.8738    4.0615    3.2492    1.6246
    0.8123    2.4369    3.2492    4.0615    4.8738    4.8738    4.8738    4.0615    3.2492    2.4369    0.8123
         0    1.6246    2.4369    3.2492    4.0615    4.0615    4.0615    3.2492    2.4369    1.6246         0
      -Inf    0.8123    1.6246    2.4369    3.2492    3.2492    3.2492    2.4369    1.6246    0.8123      -Inf
      ⋮

Translate the structuring element.

V = [2 2];
SE2 = translate(SE,V)
SE2 = 
offsetstrel is a ball shaped offset structuring element with properties:

            Offset: [15x15 double]
    Dimensionality: 2

SE2.Offset
ans = 15×15

      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf
      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf
      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf
      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf
      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf         0    0.8123    1.6246    2.4369    1.6246    0.8123         0      -Inf      -Inf
      -Inf      -Inf      -Inf      -Inf      -Inf    0.8123    1.6246    2.4369    3.2492    3.2492    3.2492    2.4369    1.6246    0.8123      -Inf
      -Inf      -Inf      -Inf      -Inf         0    1.6246    2.4369    3.2492    4.0615    4.0615    4.0615    3.2492    2.4369    1.6246         0
      -Inf      -Inf      -Inf      -Inf    0.8123    2.4369    3.2492    4.0615    4.8738    4.8738    4.8738    4.0615    3.2492    2.4369    0.8123
      -Inf      -Inf      -Inf      -Inf    1.6246    3.2492    4.0615    4.8738    5.6861    5.6861    5.6861    4.8738    4.0615    3.2492    1.6246
      -Inf      -Inf      -Inf      -Inf    2.4369    3.2492    4.0615    4.8738    5.6861    6.4984    5.6861    4.8738    4.0615    3.2492    2.4369
      ⋮

Input Arguments

collapse all

Structuring element, specified as a strel or offsetstrel object.

Translation offsets, specified as a numeric vector. Each element specifies the amount of desired translation in the corresponding dimension.

Output Arguments

collapse all

Translated structuring elements, returned as a strel or offsetstrel object.

Version History

Introduced before R2006a