Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

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)).

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™.

Code Generation support: Yes.

MATLAB Function Block support: Yes.

Examples

collapse all

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)

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)

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)

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)

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)

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

collapse all

Image to be adjusted, specified as a grayscale image.

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

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.

Data Types: single | double

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].

Data Types: single | 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).

Data Types: double

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

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

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

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

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

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

Output Arguments

collapse all

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

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

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

Data Types: single | double

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

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

collapse all

Code Generation

This function supports the generation of C code using MATLAB® Coder™. Note that if you choose the generic MATLAB Host Computer target platform, the function generates code that 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 Understanding Code Generation with Image Processing Toolbox.

When generating code, imadjust does not support indexed images.

MATLAB Function Block

You can use this function in the MATLAB Function Block in Simulink.

Introduced before R2006a

Was this topic helpful?