SlideShare a Scribd company logo
Dr.S.SHAJUN NISHA, MCA.,M.Phil.,M.Tech.,MBA.,Ph.D
Assistant Professor & Head
PG & Research Dept. of Computer Science
Sadakathullah Appa College
shajunnisha_s@yahoo.com
+91 99420 96220
INTENSITY TRANSFORMATION
& SPATIAL FILTERING
Introduction
 Spatial domain
Refers to the image plane itself
Image processing methods are based and directly
applied to image pixels
 Two principle categories of spatial processing:
Intensity transformation
Spatial filtering
=Input image
= Output image
= Operator defined
over a neighbourhood
Spatial domain processes are denoted by
• Process of small window operation are called spatial filtering
Intensity Transformation Functions
 The simplest form of the transformation T is applied on 1x1 (a
single pixel)
 The value of g at (x,y) depends only on the intensity of f at that
point, and T becomes an intensity or gray-level transformation
function.
 Simplified form as
s = T(r)
 where r denotes the intensity of f and s the intensity of g, both
at any corresponding point (x,y) in the images.
Function imadjust
 Function imadjust is the basic IPT tool for intensity
transformations of grayscale images.
Syntax
 g = imadjust(f, [low_in high_in], [low_out high_out],
gamma)
Functions imadjust and stretchlim
Command
 g1 = imadjust(f, [0 1], [1 0]);
Input Output
 g = imcomplement(f) can also be used to obtain the above
output
g2 = imadjust(f, [0.5 0.75], [0 1]);
Result of expanding the intensity range [0.5, 0.75].
g3 = imadjust(f, [ ], [ ], 2);
f=imread('cameraman.tif');
figure,imshow(f);
g1 = imadjust(f, [0 1], [1 0]);
figure,imshow(g1);
g2 = imadjust(f, [0 1], [1 0], 0.5);
figure,imshow(g2);
g3 = imadjust(f, [0 1], [1 0], 1);
figure,imshow(g3);
g4 = imadjust(f, [0 1], [1 0], 2);
figure,imshow(g4);
g5 = imadjust(f, [0.5 0.75], [0 1]);
figure,imshow(g5);
g6 = imadjust(f, [0.5 0.75], [0 1], 0.5);
figure,imshow(g6);
imhist(f);
Logarithmic and Contrast-Stretching Transformations
 Logarithmic and contrast-stretching transformations are basic tools for
dynamic range manipulation.
 Logarithm transformations are implemented using the expression
g = c*log(1 + double(f))
 where c is a constant.
 The shape of this transformation is similar to the gamma curve with the
low values set at 0 and the high values set to 1 on both scales. Note,
however, that the shape of the gamma curve is variable,
 whereas the shape of the log function is fixed.
Intensity Transformation and Spatial filtering
 Contrast-Stretching has the form
 where r represents the intensities of the input image, s the
corresponding intensity values in the output image, and E
controls the slope of the function.
 This equation is implemented in MATLAB for an entire image
as
g = 1./(1 + (m./f).^E)
Example using Log transformation to reduce dynamic range
g = im2uint8(mat2gray(log(1 + double(f))));
imshow(g)
HISTOGRAM PROCESSING & FUNCTION PLOTTING
Intensity transformation functions based on
information extracted from image intensity histograms
play a basic role in image processing, in areas such as
enhancement, compression, segmentation, and
description.
It includes histogram, histogram equalization,
histogram matching, contrast limited adaptive
histogram equalization,
 The focus of this section is on obtaining, plotting, and
using histograms for image enhancement.
Generating and Plotting Image Histograms
 The histogram of a digital image with L total possible intensity
levels in the range [0,G] is defined as the discrete function
 where is the k th intensity level in the interval [0, G] and
is the number of pixels in the image whose intensity level is
 it is useful to work with normalized histograms, obtained
simply by dividing all elements of by the total number of
pixels in the image, which we denote by n:
 The core function in the toolbox for dealing with image histograms
is imhist, which has the following basic syntax:
h = imhist(f, b)
 the normalized histogram simply by using the expression
p = imhist(f, b)/numel(f)
 numel(f) gives the number of elements in array f (i.e., the number
of pixels in the image), b is the number of bins used in forming the
histogram (if b is not included in the argument, b = 256 is used by
default). A bin is simply a subdivision of the intensity scale.
 Histograms often are plotted using bar graphs. For this purpose we
can use the function
 bar(horz, v, width)
 imhist(f)
• A stem graph is similar to a bar graph.
•The syntax is
stem(horz, v, 'color_linestyle_marker', 'fill')
where v is row vector containing the points to be plotted, and
horz is as described for bar.
>> f=imread('cameraman.tif');
>>h = imhist(f);
>> h1 = h(1:10:256);
>> horz = 1:10:256;
>> stem(horz, h1, 'fill')
>> axis([0 255 0 15000])
>> set(gca, 'xtick', [0:50:255])
>> set(gca, 'ytick', [0:2000:15000])
Histogram Equalization
• Intensity levels are continuous quantities normalized to the range
[0, 1],
•let denote the probability density function (PDF) of the
intensity levels in a given image,
• Suppose that we perform the following transformation on the
input levels to obtain output (processed) intensity levels, s,
where is a dummy variable of integration ,then PDF of intensity levels in
an output image will be
• When dealing with discrete quantities we work with histograms
and call the preceding technique histogram equalization
• Let denote the histogram associated with
the intensity levels of a given image, and recall that the values in
a normalized histogram are approximations to the probability of
occurrence of each intensity level in the image. For discrete
quantities we work with summations, and the equalization
transformation becomes
For k=1,2,…..L where is the intensity value in the output
(processed) image corresponding to value in the input image.
Histogram Equalization
 Histogram equalization is implemented in the toolbox by
function histeq,which has the syntax
 g = histeq(f, nlev)
 where f is the input image and nlev is the number of intensity
levels specified for the output image.
>> imshow(f)
>> figure, imhist(f)
>> g = histeq(f, 256);
>> figure, imshow(g)
>> figure, imhist(g)
Intensity Transformation and Spatial filtering
Histogram Matching (Specification)
The toolbox implements histogram matching using the following
syntax in
histeq:
g = histeq(f, hspec)
>> f1 = histeq(f, 256);
Spatial Filtering
Neighborhood processing consists of
(1) defining a center point,
(2) performing an operation that involves only the pixels in a
predefined neighborhood about that center point;
(3) letting the result of that operation be the “response” of the
process at that point; and
(4) repeating the process for every point in the image.
The process of moving the center point creates new
neighborhoods, one for each pixel in the input image
• The two principal terms used to identify this operation are
neighborhood processing and spatial filtering, with the second
term being more prevalent.
• If the computations performed on the pixels of the
neighborhoods are linear, the operation is called linear spatial
filtering (the term spatial convolution also used); otherwise it
is called nonlinear spatial filtering.
Linear Spatial Filtering
Intensity Transformation and Spatial filtering
Intensity Transformation and Spatial filtering
The toolbox implements linear spatial filtering using function
imfilter,
which has the following syntax:
g = imfilter(f, w, filtering_mode, boundary_options,
size_options)
The most common syntax for imfilter is
g = imfilter(f, w, 'replicate')
f = imread('peppers.png');
figure,imshow(f)
w=[256 256];
g = imfilter(f, w, 'symmetric')
figure, imshow(g)
Intensity Transformation and Spatial filtering
Standard Linear Spatial Filters:
Syntax:
W=fspecial(‘type’, parameters)
Eg:
originalRGB = imread('peppers.png’);
imshow(originalRGB)
h = fspecial('motion', 50, 45);
filteredRGB = imfilter(originalRGB, h);
figure, imshow(filteredRGB)
Intensity Transformation and Spatial filtering
Non liner spatial Filtering
Syntax
fp = padarray(f, [r c], method, direction)
Eg 1:
f=imread('peppers.png');
fp=padarray(f, [312 312], 'replicate', 'post')
figure,imshow(f);
figure,imshow(fp);
Eg 2:
>> fp = padarray(f, [3 2], 'replicate', 'post')
Intensity Transformation and Spatial filtering
Standard Non Linear Spatial Filters:
The syntax of function ordfilt2 is
g = ordfilt2(f, order, domain)
to implement a min filter (order 1) of size mxn we use the syntax
g = ordfilt2(f, 1, ones(m, n))
Eg:
>> fn = imnoise(f, 'salt & pepper', 0.2);
>> gm = medfilt2(fn);
>> gms = medfilt2(fn, 'symmetric');

More Related Content

PPTX
5. gray level transformation
MdFazleRabbi18
 
PPTX
Psuedo color
Mariashoukat1206
 
PPSX
Image Enhancement in Spatial Domain
Dr. A. B. Shinde
 
PPT
Interpixel redundancy
Naveen Kumar
 
PPTX
Image Filtering in the Frequency Domain
Amnaakhaan
 
PPSX
Color Image Processing: Basics
Dr. A. B. Shinde
 
PPT
Spatial filtering
shabanam tamboli
 
5. gray level transformation
MdFazleRabbi18
 
Psuedo color
Mariashoukat1206
 
Image Enhancement in Spatial Domain
Dr. A. B. Shinde
 
Interpixel redundancy
Naveen Kumar
 
Image Filtering in the Frequency Domain
Amnaakhaan
 
Color Image Processing: Basics
Dr. A. B. Shinde
 
Spatial filtering
shabanam tamboli
 

What's hot (20)

PPTX
Spatial Filters (Digital Image Processing)
Kalyan Acharjya
 
PPT
Chapter10 image segmentation
asodariyabhavesh
 
PPTX
Digital Image Processing
lalithambiga kamaraj
 
PPTX
Digital Image restoration
Md Shabir Alam
 
PPTX
Module 31
UllasSS1
 
PPTX
Image restoration and degradation model
AnupriyaDurai
 
PPT
Image segmentation
Md Shabir Alam
 
PPTX
Image filtering in Digital image processing
Abinaya B
 
PPTX
digital image processing
Abinaya B
 
PPTX
Image Representation & Descriptors
PundrikPatel
 
PPTX
Digital image processing
kavitha muneeshwaran
 
PPTX
Image Enhancement in Spatial Domain
DEEPASHRI HK
 
PPTX
Unit 2. Image Enhancement in Spatial Domain.pptx
swagatkarve
 
PPTX
Image Restoration (Order Statistics Filters)
Kalyan Acharjya
 
PPTX
Color image processing Presentation
Revanth Chimmani
 
PPT
Enhancement in frequency domain
Ashish Kumar
 
PPT
Enhancement in spatial domain
Ashish Kumar
 
PPTX
Image Sensing and Acquisition.pptx
RUBIN (A) JEBIN
 
PPTX
Unit3 dip
Imran Khan
 
Spatial Filters (Digital Image Processing)
Kalyan Acharjya
 
Chapter10 image segmentation
asodariyabhavesh
 
Digital Image Processing
lalithambiga kamaraj
 
Digital Image restoration
Md Shabir Alam
 
Module 31
UllasSS1
 
Image restoration and degradation model
AnupriyaDurai
 
Image segmentation
Md Shabir Alam
 
Image filtering in Digital image processing
Abinaya B
 
digital image processing
Abinaya B
 
Image Representation & Descriptors
PundrikPatel
 
Digital image processing
kavitha muneeshwaran
 
Image Enhancement in Spatial Domain
DEEPASHRI HK
 
Unit 2. Image Enhancement in Spatial Domain.pptx
swagatkarve
 
Image Restoration (Order Statistics Filters)
Kalyan Acharjya
 
Color image processing Presentation
Revanth Chimmani
 
Enhancement in frequency domain
Ashish Kumar
 
Enhancement in spatial domain
Ashish Kumar
 
Image Sensing and Acquisition.pptx
RUBIN (A) JEBIN
 
Unit3 dip
Imran Khan
 
Ad

Similar to Intensity Transformation and Spatial filtering (20)

PDF
Gonzalez, rafael,c.digitalimageprocessingusing matlab
urmia university of technology
 
PPTX
IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN.pptx
Gowthami476224
 
PPTX
Image processing second unit Notes
AAKANKSHA JAIN
 
PPTX
3rd unit.pptx
ssuser0bf6a8
 
PPT
3 intensity transformations and spatial filtering slides
BHAGYAPRASADBUGGE
 
PDF
4.intensity transformations
Yahya Alkhaldi
 
PDF
Image processing
maheshpene
 
PPTX
UNIT-2-PPT1-Image Enhancement in Spatial Domain.pptx
suresh887259
 
PPT
Digital Image Processing_ ch2 enhancement spatial-domain
Malik obeisat
 
PPTX
Digital Image Processing - Image Enhancement.pptx
DrGovindarajuSankara
 
PDF
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
ankushspencer015
 
PPTX
Image Enhancement - Point Processing
Gayathri31093
 
PPT
image processing intensity transformation
alobaidimki
 
PDF
Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...
IJSRD
 
PDF
Lec_3_Image Enhancement_spatial Domain.pdf
nagwaAboElenein
 
PPTX
Digital Image Processing Unit -2 Notes complete
shubhamsaraswat8740
 
PDF
Digital image processing - Image Enhancement (MATERIAL)
Mathankumar S
 
PDF
Digital Image Processing - Image Enhancement
Mathankumar S
 
PDF
4 image enhancement in spatial domain
Prof. Dr. Subhasis Bose
 
PDF
Image enhancement
Kuppusamy P
 
Gonzalez, rafael,c.digitalimageprocessingusing matlab
urmia university of technology
 
IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN.pptx
Gowthami476224
 
Image processing second unit Notes
AAKANKSHA JAIN
 
3rd unit.pptx
ssuser0bf6a8
 
3 intensity transformations and spatial filtering slides
BHAGYAPRASADBUGGE
 
4.intensity transformations
Yahya Alkhaldi
 
Image processing
maheshpene
 
UNIT-2-PPT1-Image Enhancement in Spatial Domain.pptx
suresh887259
 
Digital Image Processing_ ch2 enhancement spatial-domain
Malik obeisat
 
Digital Image Processing - Image Enhancement.pptx
DrGovindarajuSankara
 
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
ankushspencer015
 
Image Enhancement - Point Processing
Gayathri31093
 
image processing intensity transformation
alobaidimki
 
Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...
IJSRD
 
Lec_3_Image Enhancement_spatial Domain.pdf
nagwaAboElenein
 
Digital Image Processing Unit -2 Notes complete
shubhamsaraswat8740
 
Digital image processing - Image Enhancement (MATERIAL)
Mathankumar S
 
Digital Image Processing - Image Enhancement
Mathankumar S
 
4 image enhancement in spatial domain
Prof. Dr. Subhasis Bose
 
Image enhancement
Kuppusamy P
 
Ad

More from Shajun Nisha (18)

PPTX
Google meet and its extensions sac
Shajun Nisha
 
PPT
Dip syntax 4
Shajun Nisha
 
PPTX
Dip fundamentals 2
Shajun Nisha
 
PPTX
Dip application 1
Shajun Nisha
 
PPTX
Dip digital image 3
Shajun Nisha
 
PPTX
ICT tools
Shajun Nisha
 
PPTX
25 environmental ethics intellectual property rights
Shajun Nisha
 
PPTX
Linear regression in machine learning
Shajun Nisha
 
PPTX
Basics of research in research methodology
Shajun Nisha
 
PPTX
Auto encoders in Deep Learning
Shajun Nisha
 
PPTX
Teaching Aptitude in Research Methodology
Shajun Nisha
 
PPTX
Perceptron and Sigmoid Neurons
Shajun Nisha
 
PPTX
Mc Culloch Pitts Neuron
Shajun Nisha
 
PPTX
Image Restoration (Digital Image Processing)
Shajun Nisha
 
PPTX
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
Shajun Nisha
 
PPTX
Image processing lab work
Shajun Nisha
 
PPTX
introduction to cloud computing
Shajun Nisha
 
PPTX
online learning NPTEL
Shajun Nisha
 
Google meet and its extensions sac
Shajun Nisha
 
Dip syntax 4
Shajun Nisha
 
Dip fundamentals 2
Shajun Nisha
 
Dip application 1
Shajun Nisha
 
Dip digital image 3
Shajun Nisha
 
ICT tools
Shajun Nisha
 
25 environmental ethics intellectual property rights
Shajun Nisha
 
Linear regression in machine learning
Shajun Nisha
 
Basics of research in research methodology
Shajun Nisha
 
Auto encoders in Deep Learning
Shajun Nisha
 
Teaching Aptitude in Research Methodology
Shajun Nisha
 
Perceptron and Sigmoid Neurons
Shajun Nisha
 
Mc Culloch Pitts Neuron
Shajun Nisha
 
Image Restoration (Digital Image Processing)
Shajun Nisha
 
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
Shajun Nisha
 
Image processing lab work
Shajun Nisha
 
introduction to cloud computing
Shajun Nisha
 
online learning NPTEL
Shajun Nisha
 

Recently uploaded (20)

PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PPTX
CDH. pptx
AneetaSharma15
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
CDH. pptx
AneetaSharma15
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 

Intensity Transformation and Spatial filtering

  • 1. Dr.S.SHAJUN NISHA, MCA.,M.Phil.,M.Tech.,MBA.,Ph.D Assistant Professor & Head PG & Research Dept. of Computer Science Sadakathullah Appa College [email protected] +91 99420 96220 INTENSITY TRANSFORMATION & SPATIAL FILTERING
  • 2. Introduction  Spatial domain Refers to the image plane itself Image processing methods are based and directly applied to image pixels  Two principle categories of spatial processing: Intensity transformation Spatial filtering
  • 3. =Input image = Output image = Operator defined over a neighbourhood Spatial domain processes are denoted by • Process of small window operation are called spatial filtering
  • 4. Intensity Transformation Functions  The simplest form of the transformation T is applied on 1x1 (a single pixel)  The value of g at (x,y) depends only on the intensity of f at that point, and T becomes an intensity or gray-level transformation function.  Simplified form as s = T(r)  where r denotes the intensity of f and s the intensity of g, both at any corresponding point (x,y) in the images.
  • 5. Function imadjust  Function imadjust is the basic IPT tool for intensity transformations of grayscale images. Syntax  g = imadjust(f, [low_in high_in], [low_out high_out], gamma)
  • 6. Functions imadjust and stretchlim Command  g1 = imadjust(f, [0 1], [1 0]); Input Output  g = imcomplement(f) can also be used to obtain the above output
  • 7. g2 = imadjust(f, [0.5 0.75], [0 1]); Result of expanding the intensity range [0.5, 0.75]. g3 = imadjust(f, [ ], [ ], 2);
  • 8. f=imread('cameraman.tif'); figure,imshow(f); g1 = imadjust(f, [0 1], [1 0]); figure,imshow(g1); g2 = imadjust(f, [0 1], [1 0], 0.5); figure,imshow(g2); g3 = imadjust(f, [0 1], [1 0], 1); figure,imshow(g3); g4 = imadjust(f, [0 1], [1 0], 2); figure,imshow(g4); g5 = imadjust(f, [0.5 0.75], [0 1]); figure,imshow(g5); g6 = imadjust(f, [0.5 0.75], [0 1], 0.5); figure,imshow(g6); imhist(f);
  • 9. Logarithmic and Contrast-Stretching Transformations  Logarithmic and contrast-stretching transformations are basic tools for dynamic range manipulation.  Logarithm transformations are implemented using the expression g = c*log(1 + double(f))  where c is a constant.  The shape of this transformation is similar to the gamma curve with the low values set at 0 and the high values set to 1 on both scales. Note, however, that the shape of the gamma curve is variable,  whereas the shape of the log function is fixed.
  • 11.  Contrast-Stretching has the form  where r represents the intensities of the input image, s the corresponding intensity values in the output image, and E controls the slope of the function.  This equation is implemented in MATLAB for an entire image as g = 1./(1 + (m./f).^E)
  • 12. Example using Log transformation to reduce dynamic range g = im2uint8(mat2gray(log(1 + double(f)))); imshow(g)
  • 13. HISTOGRAM PROCESSING & FUNCTION PLOTTING Intensity transformation functions based on information extracted from image intensity histograms play a basic role in image processing, in areas such as enhancement, compression, segmentation, and description. It includes histogram, histogram equalization, histogram matching, contrast limited adaptive histogram equalization,  The focus of this section is on obtaining, plotting, and using histograms for image enhancement.
  • 14. Generating and Plotting Image Histograms  The histogram of a digital image with L total possible intensity levels in the range [0,G] is defined as the discrete function  where is the k th intensity level in the interval [0, G] and is the number of pixels in the image whose intensity level is  it is useful to work with normalized histograms, obtained simply by dividing all elements of by the total number of pixels in the image, which we denote by n:
  • 15.  The core function in the toolbox for dealing with image histograms is imhist, which has the following basic syntax: h = imhist(f, b)  the normalized histogram simply by using the expression p = imhist(f, b)/numel(f)  numel(f) gives the number of elements in array f (i.e., the number of pixels in the image), b is the number of bins used in forming the histogram (if b is not included in the argument, b = 256 is used by default). A bin is simply a subdivision of the intensity scale.  Histograms often are plotted using bar graphs. For this purpose we can use the function  bar(horz, v, width)  imhist(f)
  • 16. • A stem graph is similar to a bar graph. •The syntax is stem(horz, v, 'color_linestyle_marker', 'fill') where v is row vector containing the points to be plotted, and horz is as described for bar.
  • 17. >> f=imread('cameraman.tif'); >>h = imhist(f); >> h1 = h(1:10:256); >> horz = 1:10:256; >> stem(horz, h1, 'fill') >> axis([0 255 0 15000]) >> set(gca, 'xtick', [0:50:255]) >> set(gca, 'ytick', [0:2000:15000])
  • 18. Histogram Equalization • Intensity levels are continuous quantities normalized to the range [0, 1], •let denote the probability density function (PDF) of the intensity levels in a given image, • Suppose that we perform the following transformation on the input levels to obtain output (processed) intensity levels, s, where is a dummy variable of integration ,then PDF of intensity levels in an output image will be
  • 19. • When dealing with discrete quantities we work with histograms and call the preceding technique histogram equalization • Let denote the histogram associated with the intensity levels of a given image, and recall that the values in a normalized histogram are approximations to the probability of occurrence of each intensity level in the image. For discrete quantities we work with summations, and the equalization transformation becomes For k=1,2,…..L where is the intensity value in the output (processed) image corresponding to value in the input image.
  • 20. Histogram Equalization  Histogram equalization is implemented in the toolbox by function histeq,which has the syntax  g = histeq(f, nlev)  where f is the input image and nlev is the number of intensity levels specified for the output image. >> imshow(f) >> figure, imhist(f) >> g = histeq(f, 256); >> figure, imshow(g) >> figure, imhist(g)
  • 22. Histogram Matching (Specification) The toolbox implements histogram matching using the following syntax in histeq: g = histeq(f, hspec) >> f1 = histeq(f, 256);
  • 23. Spatial Filtering Neighborhood processing consists of (1) defining a center point, (2) performing an operation that involves only the pixels in a predefined neighborhood about that center point; (3) letting the result of that operation be the “response” of the process at that point; and (4) repeating the process for every point in the image. The process of moving the center point creates new neighborhoods, one for each pixel in the input image
  • 24. • The two principal terms used to identify this operation are neighborhood processing and spatial filtering, with the second term being more prevalent. • If the computations performed on the pixels of the neighborhoods are linear, the operation is called linear spatial filtering (the term spatial convolution also used); otherwise it is called nonlinear spatial filtering.
  • 28. The toolbox implements linear spatial filtering using function imfilter, which has the following syntax: g = imfilter(f, w, filtering_mode, boundary_options, size_options) The most common syntax for imfilter is g = imfilter(f, w, 'replicate') f = imread('peppers.png'); figure,imshow(f) w=[256 256]; g = imfilter(f, w, 'symmetric') figure, imshow(g)
  • 30. Standard Linear Spatial Filters: Syntax: W=fspecial(‘type’, parameters) Eg: originalRGB = imread('peppers.png’); imshow(originalRGB) h = fspecial('motion', 50, 45); filteredRGB = imfilter(originalRGB, h); figure, imshow(filteredRGB)
  • 32. Non liner spatial Filtering Syntax fp = padarray(f, [r c], method, direction) Eg 1: f=imread('peppers.png'); fp=padarray(f, [312 312], 'replicate', 'post') figure,imshow(f); figure,imshow(fp); Eg 2: >> fp = padarray(f, [3 2], 'replicate', 'post')
  • 34. Standard Non Linear Spatial Filters: The syntax of function ordfilt2 is g = ordfilt2(f, order, domain) to implement a min filter (order 1) of size mxn we use the syntax g = ordfilt2(f, 1, ones(m, n)) Eg: >> fn = imnoise(f, 'salt & pepper', 0.2); >> gm = medfilt2(fn); >> gms = medfilt2(fn, 'symmetric');