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 Truewhether to apply f to the list of channel values or separately to each channel value
    Masking Allregion 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 all

Basic Examples  (2)

Replace each pixel with the maximum of the color channels:

Compute the average of three color images:

Scope  (8)

Color negate a grayscale image:

Color negate an RGB 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:

Apply a function to pixels of a 3D RGB image:

Combine two 3D 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:

Convert the single-channel image to an RGB image:

Masking  (2)

Negate pixels in the specified region of interest:

Region-of-interest processing is not supported when applying a function to a list of images:

Include the mask as one of the images in the list:

Applications  (11)

Apply a gamma correction:

Color negate the image:

Covert to a single-channel image:

Display a selected channel:

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:

Compute the so-called Robert's gradient 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:

Neat Examples  (4)

Rotate color channels:

Convert an image to grayscale while preserving the red color:

Apply any coloring function to an image:

Colorize a grayscale image:

Wolfram Research (2008), ImageApply, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageApply.html (updated 2012).

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

BibTeX

@misc{reference.wolfram_2024_imageapply, author="Wolfram Research", title="{ImageApply}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/ImageApply.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_imageapply, organization={Wolfram Research}, title={ImageApply}, year={2012}, url={https://reference.wolfram.com/language/ref/ImageApply.html}, note=[Accessed: 21-November-2024 ]}