imadjust

Adjust image intensity values or colormap

Syntax

  • J = imadjust(I) example
  • J = imadjust(I,[low_in; high_in],[low_out; high_out]) example
  • J = imadjust(I,[low_in; high_in],[low_out; high_out],gamma)
  • newmap = imadjust(map,[low_in; high_in],[low_out; high_out],gamma)
  • RGB2 = imadjust(RGB1,___) example
  • gpuarrayB = imadjust(gpuarrayA,___) example

Description

example

J = imadjust(I) maps the intensity values in grayscale image I to new values in J such that 1% of data is saturated at low and high intensities of I. This increases the contrast of the output image J. This syntax is equivalent to imadjust(I,stretchlim(I)).

This function supports code generation (see Tips).

example

J = imadjust(I,[low_in; high_in],[low_out; high_out]) maps the values in I to new values in J such that values between low_in and high_in map to values between low_out and high_out.

    Note   If high_out is less than low_out, imadjust reverses the output image, as in a photographic negative.

J = imadjust(I,[low_in; high_in],[low_out; high_out],gamma) maps the values in I to new values in J, where gamma specifies the shape of the curve describing the relationship between the values in I and J.

newmap = imadjust(map,[low_in; high_in],[low_out; high_out],gamma) transforms the m-by-3 array colormap associated with an indexed image. low_in, high_in, low_out, and high_out must be 1-by-3 vectors. gamma can be a 1-by-3 vector that specifies a unique gamma value for each channel or a scalar that specifies the value used for all three channels. The rescaled colormap newmap is the same size as map.

example

RGB2 = imadjust(RGB1,___) performs the adjustment on each plane (red, green, and blue) of the RGB image RGB1. If low_in, high_in, low_out, high_out, and gamma are scalars, imadjust applies the same mapping to the red, green, and blue components of the image. To specify unique mappings for each color component of the image, specify low_in, high_in, low_out, high_out, and gamma as 1-by-3 vectors.

example

gpuarrayB = imadjust(gpuarrayA,___) performs the contrast adjustment on a GPU. The input gpuArray gpuarrayA is an intensity image, RGB image, or a colormap. The output gpuArray gpuarrayB is the same as the input image. This syntax requires the Parallel Computing Toolbox™.

Examples

expand all

Adjust Contrast of Grayscale Image

Read a low-contrast grayscale image into the workspace and display it.

I = imread('pout.tif');
imshow(I);

Adjust the contrast of the image so that 1% of the data is saturated at low and high intensities, and display it.

J = imadjust(I);
figure
imshow(J)

Adjust Contrast of Grayscale Image on GPU

Read an image into a gpuArray and then pass the gpuArray to imadjust.

I = gpuArray(imread('pout.tif'));
figure
imshow(I)

J = imadjust(I); 
figure
imshow(J)

Adjust Contrast of Grayscale Image Specifying Contrast Limits

Read a low-contrast grayscale image into the workspace and display it.

I = imread('pout.tif');
imshow(I);

Adjust the contrast of the image, specifying contrast limits.

K = imadjust(I,[0.3 0.7],[]);
figure
imshow(K)

Adjust Contrast of Grayscale Image Specifying Contrast Limits on GPU

Read an image into a gpuArray and then pass the gpuArray to imadjust.

I = gpuArray(imread('pout.tif'));
figure
imshow(I)

K = imadjust(I,[0.3 0.7],[]);
figure
imshow(K)

Adjust Contrast of RGB Image

Read an RGB image into the workspace and display it.

RGB = imread('football.jpg');
imshow(RGB)

Adjust the contrast of the RGB image, specifying contrast limits.

RGB2 = imadjust(RGB,[.2 .3 0; .6 .7 1],[]);
figure
imshow(RGB2)

Adjust Contrast of RGB Image on GPU

Read an RGB image into a gpuArray and then pass the gpuArray to imadjust, specifying contrast limits for the input image.

RGB = gpuArray(imread('football.jpg'));
RGB2 = imadjust(RGB,[.2 .3 0; .6 .7 1],[]);
figure
imshow(RGB)
figure
imshow(RGB2)

Input Arguments

expand all

I — Image to be adjustedgrayscale image

Image to be adjusted, specified as a grayscale image.

Example:

Data Types: single | double | int16 | uint8 | uint16 | uint32

[low_in; high_in] — Contrast limits for the input image[0 1] (default) | two-element numeric vector with values between 0 and 1 | 1-by-3 element vector

Contrast limits for input image, specified as a two-element numeric vector with values between 0 and 1. Values below low_in and above high_in are clipped; that is, values below low_in map to low_out, and those above high_in map to high_out. If you specify an empty matrix ([]), imadjust uses the default limits [0 1].

If the input image is a colormap, must be 1-by-3 vectors.

Example: K = imadjust(I,[0.3 0.7],[]);

Data Types: single | double

[low_out; high_out] — Contrast limits for the output image[0 1] (default) | two-element numeric vector with values between 0 and 1

Contrast limits for the output image, specified as a two-element numeric vector with values between 0 and 1. Values below low_in and above high_in are clipped; that is, values below low_in map to low_out, and those above high_in map to high_out. If you specify an empty matrix ([]), imadjust uses the default limits [0 1].

Example: K = imadjust(I,[0.3 0.7],[0.3 0.7]);

Data Types: single | double

gamma — Shape of the curve describing relationship of input and output values1 (default) | numeric value of class double

Shape of curve describing relationship of input and output values, specified as a numeric value. If gamma is less than 1, imadjust weights the mapping toward higher (brighter) output values. If gamma is greater than 1, imadjust weights the mapping toward lower (darker) output values. If you omit the argument, gamma defaults to 1 (linear mapping).

Example:

Data Types: double

map — Colormap to be adjustedm-by-3 array

Colormap to be adjusted, specified as anm-by-3 array.

Example:

Data Types: single | double | int16 | uint8 | uint16 | uint32

RGB1 — Color image to be adjustedRGB image

Color image to be adjusted, specified as an RGB image.

Example:

Data Types: single | double | int16 | uint8 | uint16 | uint32

gpuarrayA — Image to be adjusted on a GPUgpuArray

Image to be adjusted on a GPU, specified as an gpuArray containing a grayscale image, an RGB image, or a colormap.

Example: I = gpuArray(imread('pout.tif'));

Data Types: single | double | int16 | uint8 | uint16 | uint32

Output Arguments

expand all

J — Adjusted imagegrayscale image

Adjusted image, returned as a grayscale image. J has the same class as the input image.

Data Types: single | double | int16 | uint8 | uint16 | uint32

newmap — Adjusted colormapm-by-3 array

Adjusted colormap, returned as an m-by-3 array, of the same class as the input colormap.

Data Types: single | double

RGB2 — Adjusted color imageRGB image

Adjusted color image, returned as an RGB image. RGB2 has the same class as the input image.

Data Types: single | double | int16 | uint8 | uint16 | uint32

gpuarrayB — Adjusted image or colormap on a GPUgpuArray

Adjusted image or colormap on a GPU, returned as a gpuArray. The gpuArray contains a grayscale or an RGB image, or a colormap.

More About

expand all

Tips

  • This function supports the generation of C code using MATLAB® Coder™. The code generated for this function uses a precompiled, platform-specific shared library. Use of a shared library preserves performance optimizations but limits the target platforms for which code can be generated. For more information, see Code Generation Using a Shared Library.

    When generating code, imadjust does not support indexed images.

Was this topic helpful?