Professional Documents
Culture Documents
Experiment No: 01 Study of Reading & Displaying of Image
Experiment No: 01 Study of Reading & Displaying of Image
YSPMs
EXPERIMENT NO : 01
Yashoda Technical
Campus, Study of Reading & Displaying
Faculty of
of Image
Engineering, Satara.
Aim:
1. To read an image
2. To display an image
List Apparatus:
MATLAB software
of
Exper Theory:
iment
The imread function supports four general syntaxes, described below.
s The imread function also supports several other format-specific syntaxes.
Sr. No Title Page No
See Special Case Syntax for information about these syntaxes.
5 Edge detection 29
Program:
6 Morphological
clear alloperation 32
a=imread('water lilies.jpg');
7 Segmentation using thresholding
subplot(2,2,1); 35
imshow(a);
8 Based on image compression 38
title('fig1');
b=imread('sachin.png');
imshow(b);
subplot(2,2,2); Apparatus:
title('fig2'); MATLAB software
.
c=imread('sunset1.gif'); Theory:
imshow(c); Gray level transformation:
There are three basic gray level transformation.
subplot(2,2,3);
title('fig3'); Linear
Logarithmic
Power law
d=imread('winter.bmp'); The overall graph of these transitions has been shown below.
imshow(d);
subplot(2,2,4);
title('fig4');
Output:
Program:
Conclusion:
clear all
a=imread('bnw.jpg');
subplot(3,2,1);
imshow(a);
title('black n white');
EXPERIMENT No: 2
b1=255-a;
Simple Gray Level
subplot(3,2,2);
Tranformation
imshow(b1);
title('inv bnw');
Aim: To study different
c=imread('grey-flower-lovely-pretty.jpg');
gray level transformations
subplot(3,2,3);
imshow(c);
title('grey image');
b2=255-c;
subplot(3,2,4);
imshow(b2);
title('inv grey');
d==imread('small_Red_
Rose.jpg');
subplot(3,2,5);
EXPERIMENT NO: 03
imshow(d);
Study of Histogram Processing
title('color');
Aim:
b3=255-d;
a)To study and display effects of Histogram Processing
subplot(3,2,6);
b)To study Histogram equalization
imshow(b3);
title('inv color');
Apparatus:
MATLAB software
Theory:
Output:
In an image processing context, the histogram of an image normally
refers to a histogram of the pixel intensity values. This histogram is a graph
showing the number of pixels in an image at each different intensity value
found in that image. For an 8-bit grayscale image there are 256 different
possible intensities, and so the histogram will graphically display 256
numbers showing the distribution of pixels amongst those grayscale values.
Histograms can also be taken of color images --- either individual histograms
of red, green and blue channels can be taken, or a 3-D histogram can be
produced, with the three axes representing the red, blue and green channels,
Conclusion: and brightness at each point representing the pixel count. The exact output
from the operation depends upon the implementation --- it may simply be a
picture of the required histogram in a suitable image format, or it may be a
data file of some sort representing the histogram statistics.
Output:
P Conclusion:
r
o
g
r
a
m
:
clear all
a=imread('coins.gif');
b=imhist(a);
c=histeq(a);
d=imhist(c);
subplot(2,2,1);
imshow(a);
title('original image');
subplot(2,2,3);
bar(0:255,b);
axis([0,255,0,10000]);
xlabel('HISTOGRAM
ORIGINAL IMAGE');
subplot(2,2,2);
imshow(c);
title('EQUILIZED
IMAGE');
subplot(2,2,4);
bar(0:255,d);
axis([0,255,0,3000]);
xlabel('HISTOGRAM
EQUILIZED IMAGE');
EXPERIMENT NO: 04
S
Aim:
T
(a) Smoothing filters in spatial domain using averaging
U (b) Smoothing filters in spatial domain using median filter.
D
Equipment:
Y
MATLAB software
Theory:
O In statistics and image processing, to smooth a data set is to
F create an approximating function that attempts to capture
important patterns in the data, while leaving out noise or other fine-scale
structures/rapid phenomena. In smoothing, the data points of a signal are
I modified so individual points (presumably because of noise) are reduced, and
M points that are lower than the adjacent points are increased leading to a
A smoother signal. Smoothing may be used in two important ways that can aid
in data analysis (1) by being able to extract more information from the data
G as long as the assumption of smoothing is reasonable and (2) by being able to
E provide analyses that are both flexible and robust. Many
different algorithms are used in smoothing.
S
M
O
Program:
O
T Smoothening using Median filter
H
f=imread ('123.gif');
E
N subplot(1,2,1);
I imshow(f);
N title('noisy image');
G
k=10;
O [m,n]=size (f);
P for i=1:k:m-k-1;
E for j=1:k:n-k-1;
R
f1=(i:i+k-1,j:j+k-1);
A
f(i:i+k-1,j:j+k-1)=median(f1(:));
T
I end;
O end;
N subplot(1,2,2);
S
imshow(f);
title('median filter');
Smoothening using
averaging filter
f=imread ('123.gif');
subplot(1,2,1);
imshow(f);
title('noisy image');
k=10;
[m,n]=size (f);
end; Theory:
end;
Edge detection includes a variety of mathematical methods that aim at
subplot(1,2,2); identifying points in a digital image at which the image brightness changes
sharply or, more formally, has discontinuities. The points at which image
imshow(f); brightness changes sharply are typically organized into a set of curved line
segments termed edges. The same problem of finding discontinuities in one-
title('mean filter'); dimensional signals is known as step detection and the problem of finding
signal discontinuities over time is known as change detection. Edge detection
is a fundamental tool in image processing, machine vision and computer
vision, particularly in the areas of feature detection and feature extraction.
Output:
Conclusion: Program:
clear all;
I=imread('cameraman.j Conclusion:
pg');
subplot(3,2,1);
imshow(I);
title('oirginal image');
a=edge(I,'roberts');
subplot(3,2,1);
imshow(a);
title('roberts');
b=edge(I,'sobel');
subplot(3,2,3);
imshow(b);
title('sobel');
c=edge(I,'prewitt');
subplot(3,2,4);
imshow(c);
title('prewitt');
d=edge(I,'canny');
subplot(3,2,5);
imshow(d);
title('canny');
Output:
EXPERIMENT NO: 0 6
Morphological Operations
Equipment:
MATLAB software
Theory:
Morphological techniques probe an image with a small shape or template called a structuring
element. The structuring element is positioned at all possible locations in the image and it is
compared with the corresponding neighborhood of pixels. Some operations test whether the
element "fits" within the neighborhood, while others test whether it "hits" or intersects the
neighborhood
Program:
t=imread('sss.jpg');
p=size(t);
s=strel('square',2);
b=imdilate(t,s);
c=imerode(t,s);
subplot(2,2,1);
imshow(t);
title('ORIGINAL');
subplot(2,2,2);
imshow(t);
title('ORIGINAL');
subplot(2,2,3);
imshow(b);
title('DILATED');
subplot(2,2,4);
imshow(C);
title('ERODE');
Output:
Conclusion:
EXPERIMENT NO: 0 7
Segmentation using Thresholding
Equipment:
MATLAB software
Theory:
In computer vision, image segmentation is the process of partitioning a digital image into
multiple segments (sets of pixels, also known as super-pixels). The goal of segmentation is to
simplify and/or change the representation of an image into something that is more meaningful
and easier to analyze. Image segmentation is typically used to locate objects
and boundaries (lines, curves, etc.) in images. More precisely, image segmentation is the process
of assigning a label to every pixel in an image such that pixels with the same label share certain
characteristics.
The result of image segmentation is a set of segments that collectively cover the entire
image, or a set of contours extracted from the image (see edge detection). Each of the pixels in a
region are similar with respect to some characteristic or computed property, such
as color, intensity, or texture. Adjacent regions are significantly different with respect to the
same characteristic(s). When applied to a stack of images, typical in medical imaging, the
resulting contours after image segmentation can be used to create 3D reconstructions with the
help of interpolation algorithms like Marching cubes.
Program:
clear all
a=imread('123.gif');
subplot(2,3,1);
imshow(a);
title('original');
subplot(2,3,4);
imshow(a);
title('Histohram of original');
[m n]=size (a);
t=155;
for i=1:m
for j=1:n
if a(i,j)<t
b(i,j)=0;
else
b(i,j)=255;
end;
end;
end;
subplot(2,3,2);
imshow(b);
title('Threshold');
subplot(2,3,5);
imhist(b);
title('Histogram of threshold');
c=histeq(b);
subplot(2,3,3);
imshow(c);
title('Equalized');
subplot(2,3,6);
imhist(c);
title('Histogram of Equalized');
Output:
Conclusion:
EXPERIMENT NO:08
Aim:
Image compression using Discrete cosine transform
Equipment:
MATLAB software
Theory:
Image compression is a type of data compression applied to digital images, to reduce their
cost for storage or transmission. Algorithms may take advantage of visual perception and
the statistical properties of image data to provide superior results compared with generic
compression methods.
Image compression may be lossy or lossless. Lossless compression is preferred for archival
purposes and often for medical imaging, technical drawings, clip art, or comics. Lossy
compression methods, especially when used at low bit rates, introduce compression artifacts.
Lossy methods are especially suitable for natural images such as photographs in applications
where minor (sometimes imperceptible) loss of fidelity is acceptable to achieve a substantial
reduction in bit rate. Lossy compression that produces negligible differences may be called
visually lossless.
Methods for lossless image compression are:
Reducing the color space to the most common colors in the image. The selected colors are
specified in the colour palette in the header of the compressed image. Each pixel just
references the index of a color in the color palette, this method can be combined
with dithering to avoid posterization.
Chroma subsampling. This takes advantage of the fact that the human eye perceives spatial
changes of brightness more sharply than those of color, by averaging or dropping some of
the chrominance information in the image.
Transform coding. This is the most commonly used method. In particular, a Fourier-related
transform such as the Discrete Cosine Transform (DCT) is widely used: N. Ahmed, T.
Natarajan and K.R.Rao, "Discrete Cosine Transform," IEEE Trans. Computers, 90-93, Jan.
1974. The DCT is sometimes referred to as "DCT-II" in the context of a family of discrete
cosine transforms; e.g., see discrete cosine transform. The more recently developed wavelet
transform is also used extensively, followed by quantization and entropy coding.
Fractal compression.
Program:
clear all
A=imread('flow.gif');
B=dctmtx(8);
[M,N]=size(A);
B1=B(1:2, 1:2);
c=idct2(B);
subplot(1,2,1);
imshow(A);
title('oirginal image');
subplot (1,2,2);
imshow(A, [])
Output:
Conclusion: