Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

Introduction to Dig

ital Image Processi


ng (DIP)

Prepared by: Laily Azyan Binti Ramlan


What is image?
2-D function, f(x,y), where x and y are spatial (plane) coordinates, and the amplitude of f
at any pair of coordinates (x,y) is called the intensity or gray level of image at that point
Types of image
Image Types

Vector Raster
Types of image
Image Types

Vector Raster

• Shapes based on mathematical calculations • Pixel-based

• Vector programs best for creating logos, drawings and Raster programs best for editing photos and creating
illustrations, technical drawings. For images that will be continuous tone images with soft color blends
applied to physical products.

Do not scale up optimally - Image must be


• Can be scaled to any size without losing quality created/scanned at the desired usage size or larger

• Vector art can be used for many processes and easily Some processes cannot use raster formats
rasterized to be used for all processes

Depending on the complexity of the image, conversion to


vector may be time consuming
• Can be easily converted to raster

Raster images are the most common image format,


including: jpg, gif, png, tif, bmp, psd, eps and pdfs
• Common vector graphic file format: ai, cdr, svg, and eps originating from raster programs
& pdfs originating from vector programs
Common raster programs: photo editing / paint programs
such as Photoshop & Paint Shop, GIMP (free)
• Common vector programs: drawing programs such as
Illustrator, CorelDraw, Inkscape (free)
File Formats of Image
GIF - commonly used for images on the web and sprites in software programs
(Graphic Interchange Format)
JPEG - commonly used by digital cameras to store photos
(Joint Photographic Experts Group) - supports varying levels of compression, which makes it ideal for web
graphics.
PNG - commonly used on the Web and is also a popular choice for application
(Portal Network Graphics) graphics
TIFF - a graphics file format created in the 1980s to be the standard image
(Tagged Image File Format) format across multiple computer platforms
Windows BMP (BitMap) - commonly used raster graphic format for saving image files
PDF - a file format designed to present documents consistently across multiple
(Portable Document Format) devices and platforms
- can store a wide variety of data, including formatted text, vector
graphics, and raster images
What is Pixel?
• Pixel is the smallest element of an image.
• Each pixel correspond to any one value.
Pixel Resolution
• term resolution refers to the total number of count of pixels in an digital image.
• eg: if an image has M rows and N columns, then its resolution can be defined as
M X N.
• the higher is the pixel resolution, the higher is the quality of the image

Source: https://www.radiantvisionsystems.com
Concept of Bits Per Pixel
• The number of different colors in an image depends on the depth of color or bits per
pixel.
Bits per pixel Number of colors

1 bpp 2 colors
Formula :-
2 bpp 4 colors
3 bpp 8 colors
4 bpp 16 colors
5 bpp 32 colors
6 bpp 64 colors
7 bpp 128 colors
8 bpp 256 colors
10 bpp 1024 colors
64 Gray Levels 32 Gray Levels 16 Gray Levels

8 Gray Levels 4 Gray Levels 2 Gray Levels


Image Size
Size of an image = rows x columns x bpp

Eg: Assuming an image has 1024 rows and 1024 columns. And since it is a gray
scale image, it has 256 different shades of gray or it has 8 bits per pixel. Then
putting these values in the formula, we get
Size of an image = rows x cols x bpp
= 1024 x 1024 x 8
= 8388608 bits.

But since its not a standard answer that we recognize, so will convert it into our
format.
Converting it into bytes = 8388608 / 8 = 1048576 bytes.
Converting into kilo bytes = 1048576 / 1024 = 1024kb.
Converting into Mega bytes = 1024 / 1024 = 1 Mb.
MATLAB Environment

This panel allows


you to access the
project folders
and files.
shows all the
variables created
and/or imported
from files.
main area where
commands can
be entered at the
command line
Read and Display Image

RGB Image

I = imread ('flowers.jpg');
imshow (I);
whos
info = imfinfo('flowers.jpg');
info.BitDepth
Identify Bit Depth of the image

Size of an image = rows x cols x bpp (Bit Depth)


Converting it into bytes = rows x cols x bpp ÷ 8
Read and Display Image

Grayscale Image

I = imread ('flowers.jpg’);
Ig = rgb2gray (I);
imshow (Ig);
whos
Save Grayscale Image

Grayscale Image
I = imread ('flowers.jpg’);
Ig = rgb2gray (I);
imshow (Ig);
whos
imwrite (Ig, ‘flowers_gray.png’);

Save to excel:

I = imread ('flowers_gray.png’);
filename = flowers_gray.xlsx
xlswrite (filename, I);
Bit Depth of Grayscale Image
imtool function
The Image Viewer provides all the image display capabilities of imshow, which optimizes figure, axes, and image
object property settings for image display. The Image Viewer also provides access to several tools for navigating
and exploring images, such as the Pixel Region tool, Image Information tool, and the Adjust Contrast tool.
Resizing Image
Specify the Magnification Value

I = imread('flowers.jpg');
Reduced size
J = imresize(I,0.25); %reduce size
K = imresize(I,1.25); %magnify size
figure
imshow(I);
figure
imshow(J);
figure
imshow(K);
Magnified size

Original image
Specify the Size of the Output Image
- Pass imresize a vector that contains the number of rows and columns in the output image

I = imread('flowers.jpg');
figure
imshow(I);
L = imresize(I,[100 150]);
figure
imshow(L)
Image Rotation

I = imread(‘flowers.jpg’);
subplot (121), imshow (I);
J = imrotate(I,35);
subplot (122), imshow (J);
Crop a Rotated Image
I = imread(‘flowers.jpg’);
subplot (121), imshow (I);
J = imrotate(I,35, ‘crop’);
subplot (122), imshow (J);
Negative of an Image

I = imread('flowers.jpg');
subplot (121), imshow (I);

J = imcomplement(I);
subplot (122), imshow (J);
Type of Noises in Image

Gaussian noise Salt and Paper noise


It is also called as electronic noise Also known as data drop noise
because it arises in amplifiers or because statistically it drop the original
detectors. data values.
Source: thermal vibration of atoms Source: Malfunctioning of camera’s
and discrete nature of radiation of sensor cell.
warm objects.
Adding Noise to an image:

I = imread('flowers.jpg');
Ig = rgb2gray(I);

subplot (221), imshow (Ig);

Igaus = imnoise(Ig, 'gaussian', 0.02) Gaussian noise


subplot (222), imshow (Igaus);

Isp = imnoise (Ig, 'salt & pepper', 0.02)


subplot (223), imshow (Isp); Salt & Pepper noise (2%)

Isp2 = imnoise (Ig, 'salt & pepper', 0.2)


subplot (224), imshow (Isp2); Salt & Pepper noise (20%)
RESULTS:

Original image Gaussian noise

S&P noise (2%) S&P noise (20%)


Denoising salt and pepper image
I = imread('flowers.jpg');
Ig = rgb2gray(I);

Isp = imnoise (Ig, 'salt & pepper', 0.02)


subplot (121), imshow (Isp);

K = medfilt2(Isp); Median filter - value of an output pixel is determined


subplot (122), imshow (K); by the median of the neighborhood pixels

You might also like