ImageApplyIndexed
ImageApplyIndexed[f,image]
applies the function f to the list of channel values for each pixel in image, giving the row and column index of each pixel as a second argument to f.
ImageApplyIndexed[f,{image1,image2,…}]
applies f to the sequence of corresponding pixel values taken from each imagei, giving the corresponding row and column index of pixels as the last argument to f.
Details and Options
- ImageApplyIndexed[f,image] replaces the list of channel values for each pixel by the result of applying the function f to the list.
- In 2D, the part specification of each pixel is passed to f as {row,column}.
- In 3D, the part specifications are specified with {slice,row,column}.
- ImageApplyIndexed works on images with any number of channels.
- ImageApplyIndexed[f,image] returns an image of the same type as image.
- In ImageApplyIndexed[f,image], the function f can return a number or a list of any length.
- The channel values supplied to f are normally in the range 0 to 1, regardless of the underlying type used in the Image object. The function f is assumed to return channel values that are normally in the range 0 to 1.
- In ImageApplyIndexed[f,{image1,image2,…,imagen}], f is supplied with n+1 arguments.
- ImageApplyIndexed[f,{image1,image2,…}] works with any number of commensurate images.
- ImageApplyIndexed[f,{image1,image2,…}] gives an image with the largest type of imagei, clipping or truncating values if necessary.
- ImageApplyIndexed has the option Interleaving, which specifies whether f should be applied to individual channel values or to the complete list of channel values for a given pixel. The default setting is Interleaving->True.
- ImageApplyIndexed works with Image3D objects.
Examples
open allclose allBasic Examples (2)
Scope (3)
Options (3)
Interleaving (2)
Use Interleaving->False when the function should be applied to color channels separately:
Use Interleaving->False and a list of images when the function expects separate channel values:
Applications (6)
Create a five-channel image where each resulting pixel represents a combination of RGB color and position:
Normalize positions to be between 0 and 1 in each dimension:
Use pixel indices to add a 2D cosine wave to an image:
Use pixel positions to process each image quadrant differently:
Convert the image to grayscale as gradually moving from the center to the corners:
Vary the exponential rate of grayscale conversion:
Colorize an image where hue and saturation depend on the pixel's position and the brightness depends on the pixel value:
Create a filled gradient image by interpolating colors at the corners:
Possible Issues (1)
With Interleaving->False, all images should have the same number of channels:
Text
Wolfram Research (2014), ImageApplyIndexed, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageApplyIndexed.html.
CMS
Wolfram Language. 2014. "ImageApplyIndexed." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ImageApplyIndexed.html.
APA
Wolfram Language. (2014). ImageApplyIndexed. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageApplyIndexed.html