# Intensity Transformations

Introduction
1. The term spatial domain refers to the image plane itself.
2. Spatial domain techniques operate directly on the pixels of image.
3. The spatial domain processes are denoted as:
g (x,y) = T [f (x,y)]
where, f (x,y) is the input image, g (x,y) is the processed image, and T is an
operator on f.
Intensity Transformation Functions
1. imadjust
a. Function imadjust is the basic IPT tool for intensity transformations of
grayscale images.
b. Syntax:
g = imadjust (f, [low_in high_in], [low_out high_out], gamma)
c. The negative of an image can also be obtained by using
imcomplement function.
g = imcomplement (f)
2. Logarithmic and contrast stretching transformations
a. These transformations are basic tools for dynamic range
manipulation.
b. Logarithm transformations are implemented using the expression
g = c * log (1 + double (f))
c. One of the principal use of the log transformation is to compress
dynamic range.
d. When performing log transformation, the compressed values would
be brought back to the full range of the display.
e. This statement is used to do this for 8 bits,
gs = im2unit8 (mat2gray (g))
f. Use of mat2gray brings the values to the range [0,1], and im2unit8
brings them to the range [0,255]
g. The function shown in fig. (a) is
called a contrast-stretching
transformation function.
h. The function shown in fig. (b) is
called a thresholding function

3. Handling a variable number of input and/or outputs
a. Function nargin is used to check the number of arguments input into
the M-function.
b. Function nargout is used in connection with the outputs of an
M-function.
c. To check if the correct number of arguments were passed in the
body of an M-function, nargchk function is used.
4. Function to compute negative, gamma, log and contrast stretching
a. Function changeclass is used for this purpose, having syntax as.
g = changeclass (newclass, f)
where, image f is converted to the class specified in parameter newclass,
and output it as g.
5. Function used for image scaling
a. Function gscale is used for this purpose, having syntax as.
g = gscale (f, method, low, high)
where, image f is the image to be scaled.

Histogram processing and function plotting
1. Generating and plotting image histograms
a. The histogram of a digital image can be displayed by using imhist
command, having syntax:
h = imhist (f,b)
b. Histograms are also plotted using bar graphs, having syntax:
bar (horz, z, width)
c. Stem graph can also be used to plot histograms, having syntax:
stem(horz, z, ‘color_linestyle_marker’, ‘fill’)
d. Histograms are also plotted using plot command, having syntax:
plot(horz, z, ‘color_linestyle_marker’)
2. Histogram Equalization: To implement histogram equalization in the
toolbox, histeq function is used, having syntax:
h = histeq (f, nlev)
3. Histogram Matching: It is implemented in toolbox by using the syntax:
g = histeq (f, hspec)