Main Content

imadjustn

Adjust intensity values in N-D volumetric image

Description

J = imadjustn(V) maps the values in the N-D volumetric intensity image V to new values in J. imadjustn increases the contrast of the output volumetric image J.

By default, imadjustn saturates the bottom 1% and the top 1% of all pixel values. This syntax is equivalent to imadjustn(V,stretchlim(V(:))).

J = imadjustn(V,[low_in high_in]) maps the values in V to new values in the range [0, 1]. Values below low_in map to 0 and values above high_in map to 1.

example

J = imadjustn(V,[low_in high_in].[low_out high_out]) maps the values in V to new values in J such that values between low_in and high_in map to values between low_out and high_out. Values below low_in are clipped to low_out and values above high_in are clipped to high_out.

If high_out is less than low_out, then imadjustn reverses the output image volume, as in a photographic negative.

J = imadjustn(V,[low_in high_in],[low_out high_out],gamma) maps the values in V to J using a nonlinear gamma curve.

Examples

collapse all

Load a 3-D image into the workspace, then save the image as data type double.

load mristack;
V1 = im2double(mristack);

Display cross-sections of the image.

figure
slice(V1,size(V1,2)/2,size(V1,1)/2,size(V1,3)/2)
colormap gray
shading interp

Figure contains an axes object. The axes object contains 3 objects of type surface.

Adjust the image intensity values. imadjustn maps input values between 0.2 and 0.8 to the default output range of [0, 1]. imadjustn clips input values below 0.2 and above 0.8.

V2 = imadjustn(V1,[0.2 0.8],[]);

Display cross-sections of the contrast-adjusted image.

figure
slice(V2,size(V2,2)/2,size(V2,1)/2,size(V2,3)/2)
colormap gray
shading interp

Figure contains an axes object. The axes object contains 3 objects of type surface.

Input Arguments

collapse all

Volumetric intensity image, specified as an N-D numeric array.

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

Range of values in the input image, specified as a 2-element vector of the form [low_in high_in], with values in the range [0, 1]. Before adjusting intensity values, imadjustn converts the input image to class double (using im2double), rescaling values to the range [0, 1]. low_in and high_in correspond to the specified input range after conversion to double.

You can use an empty matrix ([]) for [low_in high_in] to specify the default of [0 1].

Data Types: double

Range of values in output image, specified as a 2-element vector of the form [low_out high_out], with values in the range [0, 1]. Before adjusting intensity values, imadjustn converts the input image to class double (using im2double), rescaling values to the range [0,1]. low_out and high_out correspond to the specified output range after conversion to double. After adjusting intensity values, imadjustn converts the image to the data type of the input image.

You can use an empty matrix ([]) for [low_out high_out] to specify the default of [0 1].

Data Types: double

Shape of gamma curve describing relationship between values in V and J, specified as a numeric scalar.

  • If you omit the argument, then gamma defaults to 1 and performs a linear mapping.

  • If the value is less than 1, then imadjustn weights the mapping toward higher (brighter) output values.

  • If the value is greater than 1, then imadjustn weights the mapping toward lower (darker) output values.

Data Types: double

Output Arguments

collapse all

Volume with adjusted intensity values, returned as an N-D volumetric intensity image. The output volume has the same class as the input image.

Version History

Introduced in R2017b