ImageApply
ImageApply[f,image]
applies the function f to the list of channel values for each pixel in image.
ImageApply[f,{image1,image2,…}]
applies f to the sequence of corresponding pixel values taken from each imagei.
Details and Options
- ImageApply[f,image] implements an image point operator, where the same function is applied to every pixel of an image. Most color operations such as color conversion and quantization are point operators.
- ImageApply works with 2D and 3D images with any number of channels.
- In ImageApply[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 of image. The function f is assumed to return channel values that are normally in the range 0 to 1.
- ImageApply[f,{image1,…,imagen}] implements a pixelwise image operator. The function f is supplied with a sequence of n arguments. »
- ImageApply[f,{image1,image2,…}] works with any number of commensurate images and gives an image with the largest type of imagei, clipping or truncating values if necessary.
- The following options can be given:
-
Interleaving True whether to apply f to the list of channel values or separately to each channel value Masking All region of interest to be processed - Evaluations of f may be cached to focus on speed of getting a result. »
- ImageApply[f,image] returns an image of the same type as image.
Examples
open allclose allBasic Examples (2)
Scope (8)
Color negate a grayscale image:
Reverse the elements of each channel vector:
Replace each RGB pixel by the maximum of all channel values:
Compute the maximum of corresponding pixel values in a list of grayscale images:
Apply a pure function to a sequence of pixel values in a list of RGB-color images:
Options (4)
Interleaving (2)
Use Interleaving->False when the function has to be applied to each color channel value separately:
With Interleaving->False, all images should have the same number of channels:
Applications (11)
Covert to a single-channel image:
Use built-in color gradients to add color to an image:
Add an alpha channel to a grayscale image:
Highlight a region in an image:
Compute the elementwise inverse of an image:
Pixel-wise division of two images:
Compute max intensity projection (MIP) on 3D CT data:
Create a saturated composite image:
Colorize the gradient's magnitude and orientation of an image:
Properties & Relations (2)
ImageApply returns an image of the same data type as input:
Clipping and truncation will happen when necessary:
Convert to a real type to avoid clipping and truncating:
In ImageApply[f,image], evaluations of f may be cached to focus on speed of getting a result:
Single channel "Byte" images use cached evaluations:
This may affect the result if the specified function can give different results when applied to same inputs:
Multichannel "Byte" images use cached evaluations with Interleaving->False:
Compare with the timing for an interleaved image when no caching is used:
Multichannel "Byte" images use cached evaluations with Listable functions:
Possible Issues (3)
Functions that accept lists as their input cannot be applied on single-channel images:
Functions should return a number or a list of numbers for every pixel in the image:
The same inverse function can be applied to an image with nonzero pixels:
ImageApply preserves the image data type, clipping or truncating values if necessary:
Apply the function to a "Real32" image instead:
Text
Wolfram Research (2008), ImageApply, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageApply.html (updated 2012).
CMS
Wolfram Language. 2008. "ImageApply." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/ImageApply.html.
APA
Wolfram Language. (2008). ImageApply. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageApply.html