Image Translate
This function block shifts an image horizontally and/or vertically by a specified number of pixels. The vacated area is filled with a chosen background color. X, Y and background color inputs are optional β empty values leave the image unchanged or use defaults.
π₯ Inputs
Input Image A grayscale or color image to be translated (image socket).
X displacement Horizontal shift in pixels (number socket). Positive moves the image to the right, negative to the left. Optional β when empty treated as 0.
Y displacement Vertical shift in pixels (number socket). Positive moves the image down, negative moves it up. Optional β when empty treated as 0.
Background Color Fill color for exposed background areas (pixel socket). Optional β defaults to black when not provided.
π€ Outputs
Translated Image The resulting image after translation (image socket). The output image has the same dimensions as the input; content shifted and edges filled with the chosen color.
πΉοΈ Controls
X displacement Enter the horizontal displacement in pixels. Use negative values to shift left.
Y displacement Enter the vertical displacement in pixels. Use negative values to shift up.
Background Color Pick a background color to fill new empty regions (use Pixel style input or a color-producing block).
β¨ Features
Optional inputs: leave
X displacementorY displacementempty to keep that axis unchanged.Preserves input image size; translated content is cropped to the original canvas.
Works with both grayscale and RGB images.
Background fill accepts single-channel or RGB values depending on the input image.
π Usage Instructions
Connect an image-producing block to
Input Image.Provide pixel values to
X displacementand/orY displacementto move the image.Optionally provide
Background Colorto control the fill for exposed areas.Use the
Translated Imageoutput as input for downstream blocks (display, analysis, saving).
Examples:
Move an image 50 pixels right and 20 pixels down by setting
X displacement= 50 andY displacement= 20.Shift only vertically by supplying a value to
Y displacementand leavingX displacementempty.
π Running Behavior
When the block runs it reads the input image and displacement values, shifts pixels by the requested amount, fills uncovered regions with the chosen color, and returns the translated image on the Translated Image socket. Missing displacement values are treated as zero.
π‘ Tips and Tricks
To avoid important image content being cropped after translation, add empty canvas around the image first using
Image Paddingor increase canvas size withImage ResizeandMake Imageto create a background, then translate inside the larger canvas.Use
Pixelor a smallMake Imageblock to create a precise background color and feed it intoBackground Color.Combine with
Image ROIorImage ROI Selectto translate only a cropped area, thenImage ConcatenateorCollage Imagesto reassemble/visualize results.If you need to flip or rotate content after translation, chain
Flip ImageorRotate Image Angleafter this block.For tiled layouts or composition, translate multiple slices and merge them back using
Image ConcatenateorMerge Channelsas needed.
π οΈ Troubleshooting
Issue: Important parts of the image are cut off after translation. Solution: Add margin before translating with
Image Paddingor increase canvas size usingImage Resize/Make Image, then translate.Issue: Background color does not match expected result. Solution: Ensure the
Background Colorinput provides the correct channel format (single value for grayscale, RGB triple for color). UsePixelto supply exact color.Issue: No change after providing displacements. Solution: Check that displacement inputs are connected and not empty; empty values default to zero.
Issue: Need to preserve image quality when shifting many pixels. Solution: Consider translating on a larger canvas first and avoid multiple successive crops; use downstream blocks such as
Show Imageto verify results.
Last updated
Was this helpful?