UNIT II Image Processing
What is an image?
An image is defined as a two-dimensional function,F(x,y), where x and y are spatial coordinates,
and the amplitude of F at any pair of coordinates (x,y) is called the intensity of that image at that
point. When x,y, and amplitude values of F are finite, we call it a digital image.
In other words, an image can be defined by a two-dimensional array specifically arranged in
rows and columns.
Digital Image is composed of a finite number of elements, each of which elements have a
particular value at a particular [Link] elements are referred to as picture elements,image
elements,and pixels.A Pixel is most widely used to denote the elements of a Digital Image.
Types of an image
1. BINARY IMAGE- The binary image as its name suggests, contain only two pixel
elements i.e 0 & 1,where 0 refers to black and 1 refers to white. This image is also known
as Monochrome.
2. BLACK AND WHITE IMAGE- The image which consist of only black and white color
is called BLACK AND WHITE IMAGE.
3. 8 bit COLOR FORMAT- It is the most famous image [Link] has 256 different shades
of colors in it and commonly known as Grayscale Image. In this format, 0 stands for
Black, and 255 stands for white, and 127 stands for gray.
4. 16 bit COLOR FORMAT- It is a color image format. It has 65,536 different colors in
[Link] is also known as High Color Format. In this format the distribution of color is not as
same as Grayscale image.
Image Processing
Digital Image Processing means processing digital image by means of a digital computer. We can
also say that it is a use of computer algorithms, in order to get enhanced image either to extract
some useful information.
Digital image processing is the use of algorithms and mathematical models to process and analyze
digital images. The goal of digital image processing is to enhance the quality of images, extract
meaningful information from images, and automate image-based tasks.
The basic steps involved in digital image processing are:
1. Image acquisition: This involves capturing an image using a digital camera or scanner, or
importing an existing image into a computer.
2. Image enhancement: This involves improving the visual quality of an image, such as
increasing contrast, reducing noise, and removing artifacts.
3. Image restoration: This involves removing degradation from an image, such as blurring,
noise, and distortion.
4. Image segmentation: This involves dividing an image into regions or segments, each of
which corresponds to a specific object or feature in the image.
5. Image representation and description: This involves representing an image in a way that
can be analyzed and manipulated by a computer, and describing the features of an image
in a compact and meaningful way.
6. Image analysis: This involves using algorithms and mathematical models to extract
information from an image, such as recognizing objects, detecting patterns, and quantifying
features.
7. Image synthesis and compression: This involves generating new images or compressing
existing images to reduce storage and transmission requirements.
8. Digital image processing is widely used in a variety of applications, including medical
imaging, remote sensing, computer vision, and multimedia.
Pixels
Pixels: The Atomic Units of Digital Images
At the very heart of digital imaging lie pixels, the smallest units of an image that can be displayed
and processed on a digital display. Each pixel represents a dot or a square of color in an image. In
color images, pixels are typically defined by three components: red, green, and blue (RGB), each
varying in intensity from 0 to 255. This RGB model allows for the creation of over 16 million
distinct colors by mixing these three primary colors in different proportions.
Zoom image will be displayed
Figure 1: Difference in pixels of a Grayscale image and RGB image.
Image Resolution
Image resolution is the level of detail of an image. The term applies to digital images, film images,
and other types of images. "Higher resolution" means more image detail. Image resolution can be
measured in various ways. Resolution quantifies how close lines can be to each other and still be
visibly resolved. Resolution units can be tied to physical sizes (e.g. lines per mm, lines per inch),
to the overall size of a picture (lines per picture height, also known simply as lines, TV lines, or
TVL), or to angular subtense. Instead of single lines, line pairs are often used, composed of a dark
line and an adjacent light line; for example, a resolution of 10 lines per millimeter means 5 dark
lines alternating with 5 light lines, or 5 line pairs per millimeter (5 LP/mm). Photographic lens are
most often quoted in line pairs per millimeter.
Examples of Resolution in Images
1. Picture Quality: Screen resolution is the total number of pixels that a digital display can
show us in both ways horizontal and vertical orientations. For example, HD resolution is
always typically represented by 1920x1080 pixels, 4K by 3840x2160 pixels, and 8K by
7680x4320 pixels. Higher resolutions may produce much more crisper and more refined
visuals on the screens, which is then necessary for tasks like the video editing, gaming, and
watching the high-definition media.
2. Image Resolution: The picture resolution of the digital image may determines how detailed
and sharp it is. It is commonly stated in pixels per inch (PPI) or dots per inch (DPI). For
example, standard web photographs typically have a resolution of 72-96 PPI; and the best
high-quality prints require a minimum of 300 PPI. Image resolution is that why a essential
for clear and detailed images in print and digital media, including graphic design,
photography, and printing.
PPI and DPI
What is PPI?
PPI stands for Pixels Per Inch. PPI means the number of pixels in an inch of any digital image. It
enhances the clarity, quality, resolution, and definition of the image on the screen. Having a higher
PPI means that the print will be clearer. It refers to the resolution of any digital image.
Types of PPI:
PPI is of several types such as:
• Screen PPI: It is a measurement of pixels on the screen per inch that explains and defines
the clarity and quality of the image on the device's screen.
• Print PPI: The printed image can only be clear and of good quality when the image or the
print is made with high-resolution standards.
• Scanner PPI: It describes the scanning quality of the scanner.
• Web Design PPI: It plays an important role in web designing as the web pages can be
accessed on different types of devices with various sizes of screens a laptop screen is bigger
than a smartphone screen so the resolution needs to work according to both so that the
website is clear on both the devices. We often call it the responsiveness of a website.
Uses of PPI:
• It is used in image editing.
• It is useful in Video editing.
Advantages of PPI:
• High-quality images can be produced.
• An image's resolution can be improved.
• It results in better editing.
Disadvantages of PPI:
• The application should be compatible to use on a certain device like smart phones, tablets,
MacBooks, laptops, etc.
• We often say that the pixels got cracked, this is because of low PPI.
• The size of the files like images or graphics automatically increases and occupies more
space in the memory of the system or gadgets.
What is DPI?
DPI stands for Dots Per Inch. DPI refers to the number of ink dots on a physically printed page. It
shows the clarity of the image on the printed page and refers to the printed resolution on the page.
Having a higher DPI means that the print will be sharper.
Types of DPI:
DPI is of several types such as:
• Printer DPI: It refers to the resolution of a printed image by any printer.
• Scanner DPI: Scanners use DPI to improve the quality and details of their scans.
• Mouse DPI: It refers to the movement of mouse cursor on the screen of the computer.
• Monitor DPI: It refers to the resolution of laptop or computer monitors.
Uses of DPI:
• It is used for Printing and photocopying.
• Scanning tasks can be clear.
• Graphic tablets
Advantages of DPI:
• High-quality printouts can be produced
• Precise printing is done.
• Printed texts can be properly read.
Disadvantages of DPI:
• A low DPI output can result in a blurry image (non-clear image) on the printed paper or on
the screen.
• Costs of print-outs might increase due to the high resolution of images.
• Little knowledge of DPI can result in unsatisfactory results on paper
Differences Between PPI and DPI It is related to digital images.
PPI DPI
It is related to digital images. It is related to printed image.
Higher PPI indicates that the A higher DPI indicates that the
picture is more clear. printed picture is of high quality.
It is measured in pixels per inch. It is measured in dots per inch.
It represents the size of pixels of a It represents the size of dots of a
digital image printed image.
These pictures can be seen on These pictures can be accessed
mobiles, tablets, laptops, etc. through printers
It is termed for the quality of It is termed for the quality of
pictures on the screen. pictures on the screen.
Bitmap
A bitmap (or raster graphic) is a digital image composed of a matrix of dots. When viewed at
100%, each dot corresponds to an individual pixel on a display. In a standard bitmap image, each
dot can be assigned a different color. Together, these dots can be used to represent any type of
rectangular picture.
There are several different bitmap file formats. The standard, uncompressed bitmap format is also
known as the "BMP" format or the device independent bitmap (DIB) format. It includes a header,
which defines the size of the image and the number of colors the image may contain, and a list of
pixels with their corresponding colors. This simple, universal image format can be recognized on
nearly all platforms, but is not very efficient, especially for large images.
Other bitmap image formats, such as JPEG, GIF, and PNG, incorporate compression algorithms to
reduce file size. Each format uses a different type of compression, but they all represent an image
as a grid of pixels. Compressed bitmaps are significantly smaller than uncompressed BMP files
and can be downloaded more quickly. Therefore, most images you see on the web are compressed
bitmaps.
If you zoom into a bitmap image, regardless of the file format, it will look blocky because each
dot will take up more than one pixel. Therefore, bitmap images will appear blurry if they are
enlarged. Vector graphics, on the other hand, are composed of paths instead of dots, and can be
scaled without reducing the quality of the image.
Lossy Compression
What is Lossy Compression?
Lossy Compression reduces file size by permanently removing some of the original data. It’s
commonly used when a file can afford to lose some data or if storage space needs to be significantly
freed up.
Advantages of Lossy Compression
• Smaller File Sizes: Lossy compression significantly reduces file sizes, making it ideal for
web use and faster loading times.
• Widely Supported: Many tools and software support lossy formats (e.g., JPEG for
images, MP3 for audio).
• Efficient for Multimedia: Effective for compressing multimedia files without noticeable
quality loss.
Disadvantages of Lossy Compression
• Quality Degradation: Due to data removal, lossy files may exhibit reduced quality.
• Not Suitable for Critical Data: Inappropriate for situations where data integrity is crucial.
Lossless Compression
What is Lossless Compression?
Lossless compression reduces file size by removing unnecessary metadata without any
discernible loss in picture quality. The original data can be perfectly reconstructed after
decompression.
Advantages of Lossless Compression
• No Quality Loss: Lossless compression maintains original quality during compression
and decompression.
• Suitable for Text and Archives: Ideal for text-based files, software installations, and
backups.
• Minor File Size Reduction: Reduces file size without compromising quality significantly.
Disadvantages of Lossless Compression
• Larger Compressed Files: Compared to lossy formats they compressed larger files.
• Less Efficient for Multimedia: Not as effective for multimedia files
Difference between Lossy Compression and Lossless Compression
Lossy Compression Lossless Compression
Lossy compression is the method which While Lossless Compression does not
eliminate the data which is not noticeable. eliminate the data which is not noticeable.
In Lossy compression, A file does not restore While in Lossless Compression, A file can be
or rebuilt in its original form. restored in its original form.
In Lossy compression, Data's quality is But Lossless Compression does not
compromised. compromise the data's quality.
Image File Formats
Image Format describes how data related to the image will be stored. Data can be stored in
compressed, Uncompressed, or vector format. Each format of the image has a different advantage
and disadvantage. Image types such as TIFF are good for printing while JPG or PNG, are best for
the web.
TIFF(.tif, .tiff):
Tagged Image File Format this format store image data without losing any data. It does not perform
any compression on images, and a high-quality image is obtained but the size of the image is also
large, which is good for printing, and professional printing.
JPEG (.jpg, .jpeg):
Joint Photographic Experts Group is a loss-prone (lossy) format in which data is lost to reduce the
size of the image. Due to compression, some data is lost but that loss is very less. It is a very
common format and is good for digital cameras, nonprofessional prints, E-Mail, PowerPoint, etc.,
making it ideal for web use.
GIF (.gif):
GIF or Graphics Interchange Format files are used for web graphics. They can be animated and
are limited to only 256 colors, which can allow for transparency. GIF files are typically small in
size and are portable.
PNG (.png):
PNG or Portable Network Graphics files are a lossless image format. It was designed to replace
gif format as gif supported 256 colors unlike PNG which support 16 million colors.
WebP:
Basically Google created WebP to replace JPEG as the standard format for images on the web by
shrinking image files to expedite the loading of online pages. Also WebP employs a RIFF-based
container which is based on the intra-frame coding of VP8.
HEIF (High Efficiency Image File Format):
A High Efficiency Image File Format or HEIF is an image container format which was
standardized by MPEG on the basis of the ISO base media file format to solve some problems.
The HEIF standard specifies the storage of HEVC intra-coded images and HEVC-coded image
sequences that make use of inter-picture prediction, even though HEIF can be used with any image
compression method as per requirement.
AVIF (AV1 Image File Format):
In order to benefit from contemporary compression algorithms and an entirely royalty-free image
format, the video consortium Alliance for Open Media (AO Media), which created the video
format Av1, standardized the AV1 Image File Format (AVIF) to process the needful technology. It
employs the AVIF-coded picture format and also suggests utilizing the HEIF container.
Bitmap (.bmp):
Bit Map Image file is developed by Microsoft for windows. It is same as TIFF due to lossless, no
compression property. Due to BMP being a proprietary format, it is generally recommended to use
TIFF files.
EPS (.eps):
Encapsulated PostScript file is a common vector file type. EPS files can be opened in applications
such as Adobe Illustrator or CorelDRAW.
RAW Image Files (.raw, .cr2, .nef, .orf, .sr2):
These Files are unprocessed and created by a camera or scanner. Many digital SLR cameras can
shoot in RAW, whether it be a .raw, .cr2, or .nef. These images are the equivalent of a digital
negative, meaning that they hold a lot of image information. These images need to be processed
in an editor such as Adobe Photoshop or Lightroom. It saves metadata and is used for photography.
Color Spaces: RGB, XYZ, HSV/HSL, LAB, LCH, YPbPr, YUV, YIQ,
.
1. RGB (Red, Green, Blue)
• Definition:
RGB is an additive color model where colors are created by combining red, green, and
blue light in varying intensities.
• Details:
o Used in screens, cameras, displays.
o Combining all = white; none = black.
o Device-dependent (same RGB values can look different on different displays).
2. CIE XYZ
• Definition:
CIE XYZ is a device-independent color space developed by the International
Commission on Illumination (CIE) that represents all perceivable colors using three
numerical values (X, Y, Z).
• Details:
o Y corresponds to luminance.
o Derived from human vision experiments.
o Base for many other color spaces (LAB, LUV, etc.).
o Encompasses entire visible spectrum.
3. HSV (Hue, Saturation, Value)
• Definition:
HSV is a cylindrical representation of the RGB color model that describes colors in terms
of their hue (type of color), saturation (intensity), and value (brightness).
• Details:
o Useful for color pickers and design software.
o Easier for humans to adjust than RGB.
o Not perceptually uniform.
4. HSL (Hue, Saturation, Lightness)
• Definition:
HSL is another cylindrical RGB-based color model that represents hue, saturation, and
lightness (perceived brightness).
• Details:
o Similar to HSV, but with a different method of calculating brightness.
o Lightness is midpoint between black and white.
o Common in graphic design and UI development.
5. CIELAB (or LAB)
• Definition:
LAB is a perceptually uniform color space defined by the CIE that expresses color as L*
(lightness), a* (green-red), and b* (blue-yellow) components.
• Details:
o Designed to match human color perception.
o Used for color correction, color difference (ΔE) analysis.
o Device-independent, based on CIE XYZ.
o Can describe colors outside RGB gamut.
6. LCH (Lightness, Chroma, Hue)
• Definition:
LCH is a cylindrical version of the LAB color space, with components for lightness,
chroma (saturation), and hue (color angle).
• Details:
o More intuitive than LAB for color manipulation.
o Maintains perceptual uniformity.
o Often used in professional photo editing and design.
7. YPbPr
• Definition:
YPbPr is an analog color space used in video systems, separating an image into luma (Y)
and two chroma (Pb and Pr) components.
• Details:
o Y = brightness
o Pb = blue minus luma
o Pr = red minus luma
o Used in component video (HDTV, DVD players).
o Derived from RGB, but more efficient for analog transmission.
8. YUV
• Definition:
YUV is a color encoding system used in video compression and broadcasting,
separating image into luminance (Y) and chrominance (U and V).
• Details:
o Allows chroma subsampling (e.g., 4:2:0)
o Used in JPEG, MPEG, digital video codecs.
o Derived from RGB and similar to YPbPr.
9. YIQ
• Definition:
YIQ is a color space used in analog television (NTSC) that separates signals into Y
(luma), I (in-phase chroma), and Q (quadrature chroma).
• Details:
o Optimized for bandwidth and transmission.
o I carries orange-blue detail, Q carries green-purple detail.
o Obsolete now — replaced by YUV and digital formats.
Summary Table: Definitions and Uses
Color
Definition Primary Use
Space
RGB Additive color model using red, green, and blue Displays, digital images
XYZ Device-independent model representing all visible colors Scientific color systems
HSV Cylindrical RGB model using hue, saturation, and value UI, color selection
HSL RGB model with hue, saturation, and lightness Graphics and design
Perceptually uniform model using lightness, green-red,
LAB Printing, color correction
and blue-yellow
Intuitive color
LCH Cylindrical form of LAB with lightness, chroma, and hue
manipulation
YPbPr Analog color space for separating brightness and color Component video (analog)
Color
Definition Primary Use
Space
Compression, TV
YUV Digital video model with luminance and chrominance
broadcasting
NTSC analog TV color model using luma, in-phase, and Analog broadcast
YIQ
quadrature (obsolete)
Advanced Image Concepts: Bezire Curve, Ellipsoid, Gamma Correction,
Structural Similarity Index, Deconvolution, Homography, Convolution
1. Bézier Curve
Definition:
A Bézier curve is a parametric curve frequently used in computer
graphics, image processing, and CAD to model smooth and scalable
curves.
Mathematical Form:
• A Bézier curve of degree nnn is defined as:
B(t)=∑i=0n(ni)(1−t)n−itiPi,0≤t≤1B(t) = \sum_{i=0}^{n} \binom{n}{i}
(1 - t)^{n-i} t^i P_i,\quad 0 \le t \le 1B(t)=i=0∑n(in)(1−t)n−itiPi,0≤t≤1
• Where PiP_iPi are control points.
Types:
• Linear (n=1): Straight line
• Quadratic (n=2): Parabola
• Cubic (n=3): Most common in design tools
Applications:
• Fonts, logos, vector images
• Path animation in UI and games
• Image edge smoothing
2. Ellipsoid
Definition:
An ellipsoid is a 3D analog of an ellipse. It can be used in image
processing to model 3D object shapes, regions of uncertainty, or statistical
distributions.
Equation:
(x−x0)2a2+(y−y0)2b2+(z−z0)2c2=1\frac{(x - x_0)^2}{a^2} + \frac{(y -
y_0)^2}{b^2} + \frac{(z - z_0)^2}{c^2} = 1a2(x−x0)2+b2(y−y0)2
+c2(z−z0)2=1
Applications:
• 3D object modeling (e.g., body parts, tumors)
• Covariance ellipsoids in tracking systems
• Shape analysis in 3D computer vision
3. Gamma Correction
Definition:
Gamma correction is the nonlinear adjustment of image brightness to
correct the difference between how cameras capture light and how human
vision perceives it.
Why it matters:
• Human eyes are more sensitive to dark regions than bright ones.
• Without correction, images look too dark or washed out on screens.
Formula:
Vout=Vin1/γV_{\text{out}} = V_{\text{in}}^{1/\gamma}Vout=Vin1/γ
• γ=2.2\gamma = 2.2γ=2.2 is common for displays.
Applications:
• Monitor calibration
• Video encoding (sRGB standard)
• Rendering engines and photo editing tools
4. Structural Similarity Index (SSIM)
Definition:
SSIM measures visual similarity between two images based on structural
information, not just pixel-wise differences (like MSE or PSNR).
Equation:
SSIM(x,y)=(2μxμy+C1)(2σxy+C2)(μx2+μy2+C1)(σx2+σy2+C2)SSIM(
x, y) = \frac{(2\mu_x\mu_y + C_1)(2\sigma_{xy} + C_2)}{(\mu_x^2 +
\mu_y^2 + C_1)(\sigma_x^2 + \sigma_y^2 + C_2)}SSIM(x,y)=(μx2+μy2
+C1)(σx2+σy2+C2)(2μxμy+C1)(2σxy+C2)
• μx,μy\mu_x, \mu_yμx,μy: Mean intensities
• σx2,σy2\sigma_x^2, \sigma_y^2σx2,σy2: Variances
• σxy\sigma_{xy}σxy: Covariance
Range:
• SSIM = 1 → images are identical
• SSIM = 0 → completely dissimilar
Applications:
• Video compression
• Image denoising
• Quality assessment in broadcasting or printing
5. Deconvolution
Definition:
Deconvolution is the process of removing or reversing the blurring and
distortion introduced during image formation.
Mathematical Model:
g(x)=(f∗h)(x)+η(x)g(x) = (f * h)(x) + \eta(x)g(x)=(f∗h)(x)+η(x)
• ggg: Observed image
• fff: True image
• hhh: Point Spread Function (PSF)
• ∗*∗: Convolution
• η\etaη: Noise
Goal:
Recover fff (the original image) given ggg and known or estimated hhh.
Applications:
• Astronomy (e.g., Hubble Space Telescope correction)
• Microscopy (clarifying blurred cell images)
• Medical imaging
6. Homography
Definition:
A homography is a projective transformation that maps points from one
image plane to another, assuming both planes observe the same flat
surface.
Equation:
[x′y′1]=H⋅[xy1]\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = H \cdot
\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}x′y′1=H⋅xy1
• HHH: 3×3 matrix with 8 degrees of freedom
Applications:
• Image stitching (panoramas)
• AR (Augmented Reality) overlays
• Camera motion estimation
• Perspective correction (e.g., fixing tilted documents)
7. Convolution
Definition:
Convolution is the application of a kernel (filter) to an image to extract
features or apply effects such as blurring, sharpening, and edge detection.
Formula:
(f∗g)(x,y)=∑m∑nf(m,n)⋅g(x−m,y−n)(f * g)(x, y) = \sum_m \sum_n f(m,
n) \cdot g(x - m, y - n)(f∗g)(x,y)=m∑n∑f(m,n)⋅g(x−m,y−n)
• fff: Image
• ggg: Kernel (e.g., 3x3 filter)
Common Kernels:
• Blur: All weights equal (averaging)
• Edge detection (Sobel): Detects gradients
• Sharpening: Enhances edges
Applications:
• Feature detection in CNNs
• Noise reduction, image enhancement
• Edge and object detection
Summary Table:
Concept Definition Equation / Model Application
Smooth Vector
Bézier Curve parametric Polynomial in t design,
curve animation
Concept Definition Equation / Model Application
(x/a)2+(y/b)2+(z/c)2=1(x/a)^2 3D
3D ellipse
Ellipsoid + (y/b)^2 + (z/c)^2 = modeling,
shape
1(x/a)2+(y/b)2+(z/c)2=1 uncertainty
Brightness Vout=Vin1/γV_{\text{out}} =
Gamma Displays,
adjustmen V_{\text{in}}^{1/\gamma}Vo
Correction rendering
t ut=Vin1/γ
Image
Compression
SSIM quality Structural comparison
, denoising
metric
Deconvolutio Reverse Restoration,
g=f∗h+ηg = f * h + \etag=f∗h+η
n blur/noise microscopy
Maps Stitching,
Homography planar x′=Hxx' = Hxx′=Hx AR,
points rectification
Apply Feature
Convolution kernel to (f∗g)(x,y)(f * g)(x, y)(f∗g)(x,y) extraction,
image filters