# Documentation

### This is machine translation

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

Adjust image intensity values or colormap

## Syntax

``J = imadjust(I)``
``````J = imadjust(I,[low_in high_in],[low_out high_out])``````
``````J = imadjust(I,[low_in high_in],[low_out high_out],gamma)``````
``newmap = imadjust(map,___)``
``RGB2 = imadjust(RGB,___)``
``gpuarrayB = imadjust(gpuarrayA,___)``

## Description

example

````J = imadjust(I)` maps the intensity values in grayscale image `I` to new values in `J`. By default, `imadjust` saturates the bottom 1% and the top 1% of all pixel values. This operation 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 intensity 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`. You can omit the ```[low_out high_out]``` argument, in which case, `imadjust` uses the default `[0 1]`.```
``````J = imadjust(I,[low_in high_in],[low_out high_out],gamma)``` maps intensity 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,___)` adjusts the m-by-3 array colormap associated with an indexed image. You can apply the same mapping to each channel of the colormap or specify unique mappings for each channel.```

example

````RGB2 = imadjust(RGB,___)` performs the adjustment on each plane (red, green, and blue) of the RGB intensity image `RGB`. You can apply the same mapping to the red, green, and blue components of the image or specify unique mappings for each color component.```

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

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

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

Calculate standard deviations from mean for stretching.

```n = 2; Idouble = im2double(I); avg = mean2(Idouble); sigma = std2(Idouble);```

Adjust the contrast based on standard deviation.

`J = imadjust(I,[avg-n*sigma avg+n*sigma],[]);`

Display original image and adjusted image.

```figure imshow(I) ```

```figure imshow(J)```

## Input Arguments

collapse all

Input grayscale intensity image, specified as a real, nonsparse, 2-D matrix.

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

Contrast limits for input image, specified in one of the following forms:

Contrast Limits

Input TypeValueDescription
grayscale1-by-2 vector of the form ```[low_in high_in]```Specifies the contrast limits in the input grayscale image that you want to map to values in the output image. Values must be in the range `[0 1.0]`. The value `low_in` must be less than the value `high_in`.
RGB or colormap2-by-3 array of the form ```[low_RGB_triplet; high_RGB_triplet]```Specifies the contrast limits in the input RGB image or colormap that you want to map to values in the output image or colormap. Each row in the array is an RGB color triplet. Values must be in the range `[0 1]`. The value `low_RGB_triplet` must be less than the value `high_RGB_triplet`.
RGB or colormap1-by-2 vector of the form ```[low_in high_in]```Specifies the contrast limits in the input RGB image that you want to map to values in the output image. Each value must be in the range `[0 1.0]`. The value `low_in` must be less than the value `high_in`. When you specify a 1-by-2 vector with an RGB image or colormap, `imadjust` applies the same adjustment to each color plane or channel.
`all types``[]` If you specify an empty matrix (`[]`), `imadjust` uses the default limits `[0 1]`.

`imadjust` clips value below `low_in` and above `high_in`: Values below `low_in` map to `low_out` and values above `high_in` map to `high_out`.

Data Types: `single` | `double`

Contrast limits for output image, specified in one of the following forms:

Contrast Limits

Input TypeValueDescription
grayscale1-by-2 vector of the form ```[low_out high_out]```Specifies the contrast limits of the output grayscale image. Each value must be in the range ```[0 1]```.
RGB or colormap2-by-3 array of the form ```[low_RGB_triplet; high_RGB_triplet]```Specifies the contrast limits of the output RGB image or colormap. Each row in the array is an RGB color triplet. Values must be in the range ```[0 1]```.
RGB or colormap1-by-2 vector of the form ```[low_out high_out]```Specifies the contrast limits in the output image. Each value must be in the range `[0 1]`. When you specify a 1-by-2 vector with an RGB image or colormap, `imadjust` applies the same adjustment to each plane or channel.
`all types``[]` If you specify an empty matrix (`[]`), `imadjust` uses the default limits `[0 1]`.

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

Data Types: `single` | `double`

Shape of curve describing relationship of input and output values, specified as a real, nonnegative, numeric scalar, or a 1-by-3 numeric vector. 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). If you specify a 1-by-3 vector, `imadjust` applies a unique gamma to each color component or channel.

Data Types: `double`

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

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

RGB intensity image to be adjusted, specified as a real, nonsparse, m-by-n-by-3 array.

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

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

## Output Arguments

collapse all

Adjusted grayscale output image, returned as a real, nonsparse, 2-D matrix, of the same class as the input image.

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

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

Data Types: `single` | `double`

Adjusted RGB intensity image, returned as a real, nonsparse, m-by-n-by-3 array, of the same class as the input image.

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

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