0% found this document useful (0 votes)
853 views

Mip-191bm72b Lab Manual

The document contains information about the Biomedical Engineering department and its Medical Image Processing lab course offered at Veltech Multitech Dr. Rangarajan Dr. Sakunthala Engineering College. The course aims to provide students hands-on experience with basic image processing techniques. The objectives are to enhance images using spatial and frequency domain filters, perform transforms and segmentation, evaluate compression techniques, and apply these skills to solve healthcare problems. Fifteen experiments are listed involving topics like image sampling, transforms, filtering, segmentation, color models, DICOM standards, and compression. Upon completing the course, students will be able to enhance, analyze, segment, and compress medical images to address real-world health issues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
853 views

Mip-191bm72b Lab Manual

The document contains information about the Biomedical Engineering department and its Medical Image Processing lab course offered at Veltech Multitech Dr. Rangarajan Dr. Sakunthala Engineering College. The course aims to provide students hands-on experience with basic image processing techniques. The objectives are to enhance images using spatial and frequency domain filters, perform transforms and segmentation, evaluate compression techniques, and apply these skills to solve healthcare problems. Fifteen experiments are listed involving topics like image sampling, transforms, filtering, segmentation, color models, DICOM standards, and compression. Upon completing the course, students will be able to enhance, analyze, segment, and compress medical images to address real-world health issues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 51

VELTECH MULTITECH Dr.

RANGARAJAN
Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
(AN ISO 9001:2008 CERTIFIED INSTITUTION)
(APPROVED BY AICTE, NEW DELHI & GOVT. OF TAMIL NADU AFFILIATED TO
ANNA UNIVERSITY, ACCREDITED BY NBA, NEW DELHI)
(ACCREDITED BY NAAC WITH ‘A’ GRADE)
N0.42, AVADI-VEL-TECH ROAD, CHENNAI- 600 062

2019 REGULATION

191BM72B MEDICAL IMAGE PROCESSING LAB


DEPARTMENT OF BIOMEDICAL ENGINEERING
(II YEAR B.E/IV Semester/REGULATION 2019)

Prepared by
Ms.NITHYAKALYANI.K, M.E(Ph.D)/MTS1449
Assistant Professor
DEPARTMENT OF BIO-MEDICAL ENGINEERING

VISION

 To establish teaching and research platform in medical electronics for the health and
well being of mankind

 MISSION

 To disseminate fundamental knowledge on medical electronics for professional


developments
 To propagate lifelong learning
 To impart the right proportion of knowledge, attitudes and ethics in students to enable
them take up positions of responsibility in the society and make significant
contributions

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)


The program educational objectives for the Biomedical Engineering program describe
accomplishments that graduates are expected to attain within four years after graduation.
 To enrich the students to liberate themselves in learning skills involving complex thoughts,
problem analysis and finding solutions.

 To identify opportunities and develop the level of competency in technical and


communication skills to establish their excellence in professionalism.

 To implement the versatile qualities acquired to a chosen career, by providing an impact for
the sustainable growth and success.

 To explore their ideas in research and promoting them to be exceptionally good in meeting
the challenges of innovation and creativity.

 To have a diversified knowledge in medical practices and instrumentation to recognise the


needs of society and serve people with professional ethics.

PROGRAMME SPECIFIC OUTCOMES (PSOs)

S.NO PROGRAM SPECIFIC OUTCOMES

Able to understand the mathematical and physical foundations of biomedical engineering and
1. how these are applied in the analysis of biological systems for biomedical instruments and
technological advancement for health care. (Understand)
Able to design a variety of electronic devices and software for applications including biomedical
2. instrumentation, physiological measurement, rehabilitation engineering and medical imaging &
informatics. (Design)
Able to meet desired needs within realistic constraints such as economic, environmental, social,
3. ethical, health and safety, manufacturability and sustainability. (Society, Environmental,
Sustainability)
DEPARTMENT OF BIO-MEDICAL ENGINEERING

POs Programme Outcomes (POs)

Be fundamentally strong in life sciences and to apply the knowledge of


PO1 engineering sciences in solving mathematical and scientific problems related to
healthcare.
Be able to Identify, formulate and analyze complex problems related to
PO2 biomedical and their solutions using principles of mathematics, natural science
and engineering.
Be able to design and develop biomedical devices to meet the societal and
PO3
environmental requirements.

Be able to use research knowledge and methods to analyze, investigate complex


PO4
problems to find suitable conclusions related to biomedical engineering.

Be able to learn necessary skills/techniques to develop mathematical models and


PO5
to implement appropriate software tools in the design of health care devices.

Be able to apply contextual knowledge to assess societal, health and safety


PO6
related issues relevant to biomedical field

Be able to understand the impact of medical engineering problems in a global,


PO7
economical and societal context.

PO8 Be able to understand professional, social and ethical responsibilities

Be able to function effectively as an individual, entrepreneur and as a member or


PO9
a leader in multi-disciplinary streams.
Be proficient in English language in order to communicate effectively on
PO1
complex engineering activities on a global scale and to make comprehensive
0
reports and presentations.
PO1 Function effectively and to demonstrate financial and managerial skills to
1 accomplish projects.

PO1 Engage in life-long learning to recognize the latest technological changes to meet
2 the societal demands.
191BM72B MEDICAL IMAGE PROCESSING LAB LTPC
0021
COURSE OBJECTIVES:

 To practice the basic image processing techniques.


 To compute magnitude and phasor representation of images.
 To understand the concepts of image restoration and segmentation.
 To explore the applications of image processing techniques.

LIST OF EXPERIMENTS:

1. Image sampling and quantization


2. Analysis of spatial and intensity resolution in MRI images
3. Intensity transformation of images.
4. DFT analysis of images
5. Transforms (Walsh, Hadamard, DCT, Haar)
6. Histogram Processing and Basic Thresholding functions
7. Image enhancement for CT images using spatial filtering
8. Image Enhancement- Filtering in frequency domain
9. Image segmentation – Edge detection, line detection and point detection.
10. Basic Morphological operations.
11. Region based Segmentation
12. Segmentation using watershed transformation
13. Analysis of images with different color models.
14. Study of DICOM standards
15. Image compression techniques
16. Image restoration
17. A mini project based on medical image processing

OUTCOMES:
At the end of the course, the student should be able to:
1. Perform enhancing operations on the image using spatial filters and frequency domain
filters.
2. Use transforms and analyse the characteristics of the image.
3. Perform segmentation operations in the images.
4. Estimate theefficiency of the compression technique on the images.
5. Apply image processing technique to solve real health care problems.
191BM72B MEDICAL IMAGE PROCESSING LAB LTPC
0021
LIST OF EXPERIMENTS:

1. Image sampling and quantization


2. Analysis of spatial and intensity resolution in MRI images
3. Intensity transformation of images.
4. DFT analysis of images
5. Transforms (Walsh, Hadamard, DCT, Haar)
6. Histogram Processing and Basic Thresholding functions
7. Image enhancement for CT images using spatial filtering
8. Image Enhancement- Filtering in frequency domain
9. Image segmentation – Edge detection, line detection and point detection.
10. Basic Morphological operations.
11. Region based Segmentation
12. Segmentation using watershed transformation
13. Analysis of images with different color models.
14. Study of DICOM standards
15. Image compression techniques
16. Image restoration
17. A mini project based on medical image processing
191BM72B MEDICAL IMAGE PROCESSING LAB
Topic wise Mapping with POs and PSO’s

PROGRAM OBJECTIVE(PO) PSO


SUBJECT COURSE
NAME OUTCOMES 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3

Perform enhancing
operations on the image
using spatial filters and 3 1 2 3 3 - - - - - - 1 3 - -

frequency domain filters.

Use transforms and analyse


the characteristics of the 3 3 2 3 3 - - - - - - 1 3 1 -
image.
MEDICAL
IMAGE Perform segmentation
PROCESSING operations in the images. 3 3 2 3 3 - - - - - - 1 3 1 -

LAB
Estimate theefficiency of
the compression technique 3 3 3 3 3 - - - - - - 1 3 1 -
on the images.

Apply image processing


technique to solve real 3 3 3 3 3 - - - - - - 1 3 1 -
health care problems.

1 – Low 2 – Medium 3 – High


Course Outcome:
At the end of the semester the students can be able to:

Course Cognitiv
Course Outcome Statements Linked POs & PSOs
Outcome e Level
Perform enhancing operations
on the image using spatial PO1,PO2,PO3.PO4,PO5
CO1 K4
filters and frequency domain PSO1,PSO2
filters
Use transforms and analyse the
PO1,PO2,PO3.PO4,PO5
CO2 characteristics of the image. K3 PSO1,PSO2

Perform segmentation
PO1,PO2,PO3.PO4,PO5
CO3 operations in the images. K3
PSO1,PSO2

Estimate theefficiency of the


compression technique on the PO1,PO2,PO3.PO4,PO5
CO4 K5
images. PSO1,PSO2

Apply image processing


technique to solve real health PO1,PO2,PO3.PO4,PO5
CO5 K3
care problems. PSO1,PSO2

K1-Remember, K2-Understand, K3-Apply, K4-Analysis, K5- Evaluation, K6- Creativity


191BM72B MEDICAL IMAGE PROCESSING LAB
LIST OF EXPERIMENTS WITH CO MAPPING

SL NO NAME OF THE EXPERIMENTS CO

1 Image sampling and quantization CO1

2 Analysis of spatial and intensity resolution in MRI images CO1

3 Intensity transformation of images. CO1

4 DFT analysis of images CO1

5 Transforms (Walsh, Hadamard, DCT, Haar) CO2

6 Histogram Processing and Basic Thresholding functions CO1

7 Image enhancement for CT images using spatial filtering CO1

8 Image Enhancement- Filtering in frequency domain CO1

9 Image segmentation – Edge detection, line detection and point detection. CO3

Basic Morphological operations CO3


10
11 Region based Segmentation CO3
12 Segmentation using watershed transformation CO3
13 Analysis of images with different color models. CO4
14 Study of DICOM standards CO4
15 Image compression techniques CO4
16 Image restoration CO4
A mini project based on medical image processing CO5
17
EX NO : 1 IMAGE SAMPLING AND QUANTIZATION
DATE :
AIM
To perform sampling and quantization of an image at different rates using MATLAB.
REQUIREMENTS
PC with MATLAB software.
ALGORITHM
IMAGE SAMPLING
1) Read the image.
2) Take sampling rate as 4.
3) Sample the image in 2D at sample rate 4.
4) Display the sampled image.
5) Repeat steps 2,3,4 for different sampling rates as 16,64,etc.,

IMAGE QUANTISATION
1) Load image.
2) Convert to gray scale image.
3) Quantize image with particular rate.
4) Display quantized image.

PROGRAMS
% IMAGE SAMPLING %

clc ;
close all;
clear all;
a=imread('Desert.jpg');
subplot(2,2,1);
imshow(a);
title('original image');
subsample=4;
s=a(1:subsample:end,1:subsample:end);
subplot(2,2,2);
imshow(s);
title('sampled image at sample rate 4');
subsample=16;
s=a(1:subsample:end,1:subsample:end);
subplot(2,2,3);
imshow(s);
title('sampled image at sample rate 16');
subsample=64;
s=a(1:subsample:end,1:subsample:end);
subplot(2,2,4);
imshow(s);
title('sampled image at sample rate 64');

% IMAGE QUANTISATION %

clc;
close all;
clear all;
a=imread('Desert.jpg');
subplot(2,2,1);
imshow(a);
title('original image');
subsample=16;
s=a(1:subsample:end,1:subsample:end);
subplot(2,2,2);
imshow(s);
title('sampled image at sample rate 4');
thresh=multithresh(s,2);
S1=imquantize(s,thresh);
rgb=label2rgb(S1);
subplot(2,2,4);
imshow(rgb);
title('Quantized image at sample rate 4');
OUTPUT :
IMAGE SAMPLING

IMAGE QUANTIZATION

RESULT :
Thus the given image is sampled and quantized at different sampling and quantization rates using
MATLAB .
EX NO :2 ANALYSIS OF SPATIAL AND INTENSITY RESOLUTION OF MRI IMAGES
DATE:

AIM
To analyze spatial and intensity resolution of given input image using MATLAB. The analyses to
perform are,
a) The effect of changing the number of gray levels on the quality of image.
b) The effect of changing spatial resolution on the quality of image

REQUIREMENTS
PC with MATLAB software.

ALGORITHM
SPATIAL RESOLUTION
1) Read the image.
2) Display the original image.
3) Convert the colour image to gray scale image.
4) Resize the grayscale image to different resolution.
5) Display images with different spatial resolution.

INTENSITY RESOLUTION
1) Load the image.
2) Display the original image.
3) Set the bits per pixel of the image.
4) Display the image with new bits per pixel.
5) Repeat the steps 3 & 4 with different bits per pixel and display the image.

PROGRAM
% SPATIAL RESOLUTION%

clc;
close all;
clear all;
a=imread('Desert.jpg'); %reads the image
subplot(3,2,1);
imshow(a); %displays the image
title('original image');
b=rgb2gray(a);
subplot(3,2,2);
imshow(b); %displays the image
title('gray image');
r1=imresize(b,[256 256]);
subplot(3,2,3);
imshow(r1); %displays the image
title('image-256x256');
r2=imresize(r1,[128 128]);
subplot(3,2,4);
imshow(r2); %displays the image
title('image-128x128');
r3=imresize(r2,[64 64]);
subplot(3,2,5);
imshow(r3); %displays the image
title('image-64x64');
r4=imresize(r3,[32 32]);
subplot(3,2,6);
imshow(r4); %displays the image
title('image-32x32');

%INTENSITY RESOLUTION OF IMAGES %

clc;
clear all;
close all;
a= imread('Desert.jpg'); %reads the image
subplot(2,2,1);
imshow(a); %displays the image
title('8 bits per pixel-256 gray levels');
n=7;
maxvalue=(2^n)-1;
newimage=a*(maxvalue/256);
subplot(2,2,2);
imshow(newimage,[]);%displays the image
title('7 bits per pixel-128 gray levels');
n=6;
maxvalue=(2^n)-1;
newimage=a*(maxvalue/256);
subplot(2,2,3);
imshow(newimage,[]);%displays the image
title('6 bits per pixel-64 gray levels');
n=4;
maxvalue=(2^n)-1;
newimage=a*(maxvalue/256);
subplot(2,2,4);
imshow(newimage,[]);%displays the image
title('4 bits per pixel-16 gray levels');
OUTPUT:

SPATIAL RESOLUTION

INTENSITY RESOLUTION

RESULT:
Thus the spatial resolution and intensity resolution of the given image are analyzed using
MATLAB.
EX NO:3 INTENSITY TRANSFORMATION OF IMAGES
DATE:

AIM
To transform the intensity of the given image by arithmetic operations using MATLAB.

REQUIREMENTS
PC with MATLAB software.

ALGORITHM
1) Read the image.
2) Display the original image.
3) Intensity of the given image is transformed using addition, subtraction, multiplication and
division.
4) Display all intensity transformed images.
PROGRAM
% INTENSITY RESOLUTION OF IMAGES USING ARITHMETIC OPERATIONS %
clc;
clear all;
close all;
a= imread('Angel.jpg'); %reads the image
subplot(3,2,1);
imshow(a); %displays the image
title('original image');
v=a+25;
subplot(3,2,3);
imshow(v); %displays the image
title('intensity transformed image +25');
w=a-50;
subplot(3,2,4);
imshow(w); %displays the image
title('intensity transformed image -50');
x=a*50;
subplot(3,2,5);
imshow(x); %displays the image
title('intensity transformed image *50');
y=a/5;
subplot(3,2,6);
imshow(y); %displays the image
title('intensity transformed image /5');
OUTPUT:
INTENSITY TRANSFORMATION OF IMAGES

RESULT:
Thus the intensity of the given image are transformed using arithmetic operations using MATLAB
software.

EX NO:4 DFT ANALYSIS OF IMAGES


DATE:

AIM
To perform Discrete fourier transform and inverse discrete fourier transform of a image for
frequency domain analysis using MATLAB.

REQUIREMENTS
PC with MATLAB software.

ALGORITHM
1) Import the image.
2) Display the original image.
3) Apply FFT.
4) Shift the origin.
5) Apply IFFT for FFT shifted image.
6) Reshift the origin.
7) Apply IFFT for the reshifted image.

PROGRAM
% DFT ANALYSIS OF IMAGES %
clear all;close all;
a=imread('Desert.jpg');% IMPORT IMAGE
subplot(3,3,1);
imshow(a); %DISPLAY IMAGE
title('Imported Image');
%2D FAST FOURIER TRANSFORMATION
y= fft2(a);
subplot(3,3,2);
imshow(y);
title('FFT of the given image');
%SHIFTING OF ORIGIN
z= fftshift(y);
subplot(3,3,3);
imshow(z);
title('FFT with the shifted origin');
%INVERSE FFT
n= ifft2(z);
n1=uint8(n);
subplot(3,3,4);
imshow(n1);
title('IFFT of the shifted image');
%RESHIFTING OFTHEORIGIN
m= ifftshift(z);
subplot(3,3,5);
imshow(m);title('FFT reshifted to the original position');
%INVERSEFFT
n= ifft2(m);
n1=uint8(n);
subplot(3,3,6);
imshow(n1);
title('IFFT of the reshifted image');
OUTPUT:
DFT ANALYSIS OF THE IMAGES

RESULT :
Thus the discrete fourier transform and inverse discrete fourier transform of are applied to
the given image and displayed with the help of MATLAB software.

EX NO: 5 TRANSFORMS (WALSH, HADAMARD, DCT, HAAR)


DATE :

AIM
To perform Walsh-hadamard Transform, Discrete Cosine Transform and Haar Transform

REQUIREMENTS
PC with MATLAB software.

ALGORITHM
WALSH HADAMARD TRANSFORM
1) Read and display the image
2) Convert to 2 dimensional gray scale image
3) Apply Walsh-hadamard Transform with order 512
4) Apply inverse Walsh-hadamard Transform to transformed image
5) Repeat step 3 and 4 for order 1024
6) Display the images

DISCRETE COSINE TRANSFORM


1) Load and display the image
2) Convert to 2 dimensional gray scale image
3) Apply 2 dimension Discrete Cosine Transform
4) Apply inverse 2 dimension Discrete Cosine Transform to transformed image
5) Display 2 dimensional 8 bit unsigned integer matrix images

HAAR TRANSFORM
1) Load and display the image
2) Apply 2 dimension Discrete Wavelet Transform in haar mode to single precision image
matrix
3) Display the image after first level degradation
4) Again apply 2 dimension Discrete Wavelet Transform to degraded image
5) Display the image after second level degradation
6) Apply 2 dimension Inverse Discrete Wavelet Transform in haar mode
7) Display Inverse wavelet transformed images

PROGRAM
% WALSH HADAMARD TRANSFORMS
close all;
imgA=imread('C:\Users\Public\Pictures\Sample Pictures\Desert.jpg');
imgA=rgb2gray(imgA);
imgA=double(imgA);
N=512;
y=fwht(imgA,N); %image is longer than N, image is truncated
subplot(2,2,1);
imshow(y);
title('Truncated 512-point discrete Walsh–Hadamard transform');
a=ifwht(double(y));
subplot(2,2,2);
imshow(uint8(a));
title('Truncated 512-point inverse discrete Walsh–Hadamard transform');
N=1024;
y=fwht(imgA,N);%image is shorter than N, image is padded with zero
subplot(2,2,3);
imshow(y);
title('Zero padded 1024-point discrete Walsh–Hadamard transform');
a=ifwht(double(y));
subplot(2,2,4);
imshow(uint8(a));
title('Zero padded 1024-point inverse discrete Walsh–Hadamard transform');

%DISCRETE COSINE TRANSFORMS


clc;
RGB=imread('C:\Users\Public\Pictures\Sample Pictures\Desert.jpg');
subplot(3,2,1);
imshow(RGB);
title('RGB Image');
i=rgb2gray(RGB);
subplot(3,2,2);
imshow(i);
title('Gray Image');
j=dct2(i);
subplot(3,2,3);
imshow(j);
title('2D DCT Image');
k=idct2(j);
subplot(3,2,4);
imshow(k);
title('2D IDCT Image');
l=uint8(k)
subplot(3,2,5);
imshow(l);
title('2D IDCT unsigned 8 bit int matrix Image');

%HAAR TRANSFORMS
clc;
x=imread('C:\Users\Public\Pictures\Sample Pictures\Desert.jpg');
subplot(3,2,1);
imshow(x);
title('Orginal image');
[a b c d]=dwt2(single(x),'haar');
y=[uint8(a),b; c,d];
subplot(3,2,2);
imshow(y);
title('Image after first level degradation');
[a1 b1 c1 d1]=dwt2(a,'haar');
y1=[a1,b1; c1,d1];
y2=[uint8(y1),b; c,d];
subplot(3,2,3);
imshow(y2);
title('Image after Second level degradation');
x1=idwt2(a,b,c,d,'haar');
subplot(3,2,4);
imshow(uint8(x1));
title('First inverse wavelet transform');
x2=idwt2(a1,b1,c1,d1,'haar');
subplot(3,2,5);
imshow(uint8(x2));
title('Second inverse wavelet transform');

OUTPUT
WALSH HADAMARD TRANSFORM

DISCRETE COSINE TRANSFORM

HAAR TRANSFORMS
RESULT
Thus Walsh-hadamard Transform, Discrete Cosine Transform and Haar Transform are
performed using MATLAB

EX NO: 6 HISTOGRAM PROCESSING AND BASIC THERSHOLDING


FUNCTIONS
DATE :

AIM
To perform histogram processing and basic thresholding functions for the given input image
and to apply histogram equalization on given input image.

REQUIREMENTS
PC with MATLAB software

ALGORITHM:
1) Load an image
2) Display the histogram of the loaded image
3) Enhance the contrast of the image using histogram equalization
4) Display the contrast-enhanced image

PROGRAM
close all;
a=imread('Desert.jpg');
subplot(3,3,1);
imshow(a);
title('Orginal image');
b=rgb2gray(a);
subplot(3,3,2);
imshow(b);
title('Grayscale image');
subplot(3,3,3);
imhist(b);
title('histogram of orginal image');
c=histeq(b);
subplot(3,3,4);
imshow(c);
title('Equalized image');
subplot(3,3,5);
imhist(c);
title('histogram of equalized image');
d=adapthisteq(b);
subplot(3,3,7);
imshow(d);
title('Adaptive histogram equalised image');
subplot(3,3,8);
imhist(d);
title('histogram of adaptive equalized image');

% THRESHOLDING OF IMAGE
function thresholding
global H Index;
B=imread('C:\Users\VM5606\Desktop\light1.jpg'); % Read image
subplot(2,2,1);
imshow(B); % Display
title('Original image');
V=reshape(B,[],1); % Reshape image
G=hist(V,0:255); % Histogram of the image
H=reshape(G,[],1); % Reshape image
Ind=0:255;
Index=reshape(Ind,[],1);
result=zeros(size([1 256]));
for i=0:255
[wbk,varbk]=calculate(1,i);
[wfg,varfg]=calculate(i+1,255);
result(i+1)=(wbk*varbk)+(wfg*varfg);
end

%Find the minimum value in the array


[X,val]=min(result);
tval=(val-1)/256;
bin_im=im2bw(B,tval); % Image converted to binary with thresholding
subplot(2,2,2);
imshow(bin_im);
title('Converted image with the specified threshold level');

function [weight,var]=calculate(m,n)
%Weight Calculation
weight=sum(H(m:n))/sum(H);

%Mean Calculation
value=H(m:n).*Index(m:n);
total=sum(value);
mean=total/sum(H(m:n));
if(isnan(mean)==1)
mean=0;
end

%Variance calculation
value2=(Index(m:n)-mean).^2;
numer=sum(value2.*H(m:n));
var=numer/sum(H(m:n));
if(isnan(var)==1)
var=0;
end

end

end

OUTPUT
HISTOGRAM PROCESSING

BASIC THRESHOLDING FUNCTIONS

RESULT
Thus Histogram thresholding functions are processed for the given input image and Histogram
equalization outputs are plotted using MATLAB successfully.

EX NO: 7 IMAGE ENHANCEMENT FOR CT IMAGES- SPATIAL FILTERING


DATE :
AIM
To enhance the image in spatial domain using various spatial filtering techniques

REQUIREMENTS
PC with MATLAB software

ALGORITHM
1) Read and display the image
2) Design simple filter
3) Filter the image with zero pad, replicate, symmetric and circular mode
4) Add noise to the image
5) Design special filters like Average, Unsharp, Motion blurred, Blur, Gaussian, Log, and
Laplacian
6) Filter the image using special filters and display the filtered image

PROGRAM

clc;
clear all;
close all;
im=imread('C:\Users\Public\Pictures\Sample Pictures\Light house.jpg');
subplot(3,4,1);
imshow(im);
title('Original');
h = ones(5,5)/20;
zer_pad=imfilter(im,h);
subplot(3,4,2)
imshow(zer_pad);
title('Zero-Padded')
repl=imfilter(im,h,'replicate');
subplot(3,4,3)
imshow(repl);
title('Replicate')
sym=imfilter(im,h,'symmetric');
subplot(3,4,4)
imshow(sym);
title('Symmetric')
cirl=imfilter(im,h,'circular');
subplot(3,4,5)
imshow(cirl);
title('Circular')
J = imnoise(im,'salt & pepper',0.02);
h1=fspecial('average',5); % Removal of noise by averaging
avg1=imfilter(J,h1);
subplot(3,4,6)
imshow(avg1);
title('Average');
h2=fspecial('unsharp');
unsp=imfilter(im,h2);
subplot(3,4,7)
imshow(unsp);
title('Unsharp');
h3=fspecial('motion',35,65);
motion_blur=imfilter(im,h3,'replicate');
subplot(3,4,8);
imshow(motion_blur);
title('Motion blurred');
h4=fspecial('disk',20);
blur=imfilter(im,h4);
subplot(3,4,9);
imshow(blur);
title('Blur');
h5=fspecial('gaussian',3,0.4);
gaus=imfilter(im,h5);
subplot(3,4,10);
imshow(gaus);
title('Gaussian');
h6=fspecial('log',5,0.3);
logg=imfilter(im,h6);
subplot(3,4,11);
imshow(logg);
title('Log');
h7=fspecial('laplacian',0.1);
lapl=imfilter(im,h7);
subplot(3,4,12);
imshow(lapl);
title('Laplacian');
OUTPUT

IMAGE ENHANCEMENT- SPATIAL FILTERING

RESULT

Thus Image Enhancement process is carried out in spatial domain for an input image using
various spatial filtering techniques and corresponding outputs are plotted and analyzed.
EX NO: 8 IMAGE ENHANCEMENT- FILTERING IN FREQUENCY DOMAIN
DATE :

AIM
To perform image enhancement by filtering in frequency domain.

REQUIREMENTS
PC with MATLAB software

ALGORITHM

1) Load the given image


2) Apply FFT
3) Shift the origin
4) Filter the given image
5) Re-shift the origin
6) Apply Inverse fourier transform

PROGRAM

clear all;
clc;
x1=imread('Koala.jpg');
x=rgb2gray(x1);
subplot(2,2,1);
imshow(x);
title('The given image');
% Butterworth low pass filter
fc=30;
fc2=fc*fc;
r=1;
[m,n]=size(x);
f=fft2(x);
subplot(2,2,2);
imshow(f);
title('FFT of the given image');
fs=fftshift(f);
mc=round(m/2);
nc=round(n/2);
b=zeros(m,n);
fori=1:m
for j=1:n
d=(i-mc).^2+(j-nc).^2;
b(i,j)=1/(1+((d/fc2).^(2*r)));
end
end
h=fs .* b;
% y=ifftshift(h);
y1=abs(ifft2(h));
y2=uint8(y1);
subplot(2,2,3);
imshow(y2);
title('Smoothened image using butterworthlowpass filter');
% Butterworth high pass filter
fc=1.2;
fc2=fc*fc;
fori=1:m
for j=1:n
d=(i-mc).^2+(j-nc).^2;
b(i,j)=1/(1+((fc2/d).^(2*r)));
end
end
h=fs.*b;
y1=abs(ifft2(h));
y2=uint8(y1);
subplot(2,2,4);
imshow(y2);
title('Sharpened image using butterworthhighpass filter');
OUTPUT

IMAGE ENHANCEMENT- FILTERING IN FREQUENCY DOMAIN

RESULT

The given image has been filtered using a frequency domain filter.
EX.NO: 9 IMAGE SEGMENTATION – EDGE DETECTION, LINE DETECTION
AND POINT DETECTION
DATE:

AIM:
To perform segmentation of an image by edge detection, line detection and point detection
techniques using MATLAB.

REQUIREMENTS:
PC with MATLAB software.

ALGORITHM:
EDGE DETECTION
1) Read the image from file location.
2) Convert into gray-scale image.
3) Perform edge detection of the image with Prewitt, Sobel, Canny, Roberts, Log and Zero-
cross techniques.
4) Display the result.

LINE DETECTION
1) Read the image from file location.
2) Convert into gray-scale image.
3) Perform edge detection of the image with Canny edge detection technique.
4) Detect the lines present in the image using houghline tranform.
5) Display the result.

POINT DETECTION
1) Read the image from file location.
2) Convert into gray-scale image.
3) Set threshold for the points to be detected.
4) Detect the points present in an image using detectFASTfeatures.
5) Display the result.

PROGRAM:
% EDGE DETECTION
clc;
clear all;
close all;
x= imread('C:\Users\HP\Pictures\Nature\macaw4.jpg'); % Read the image
subplot(3,3,1);
imshow(x); % Display the original image
title('Original image');
x1=rgb2gray(x); % RGB -> Gray conversion
subplot(3,3,2);
imshow(x1);
title('Grayscale image'); % Display Gray scale image
b= edge(x1,'prewitt'); % Perform Prewitt edge detection
subplot(3,3,3);
imshow(b); % Display image
title('Edge detection using Prewitt edge detector');
c= edge(x1, 'sobel'); % Perform Sobel edge detection
subplot(3,3,4);
imshow(c); % Display image
title('Edge detection using Sobel edge detector');
d= edge(x1,'canny'); % Perform Canny edge detection
subplot(3,3,5);
imshow(d); % Display image
title('Edge detection using Canny edge detector');
e= edge(x1,'roberts'); % Perform Roberts edge detection
subplot(3,3,6);
imshow(e); % Display image
title('Edge detection using Roberts edge detector');
f= edge(x1,'log'); % Perform Log edge detection
subplot(3,3,7);
imshow(f); % Display image
title('Edge detection using log edge detector');
g= edge(x1,'zerocross'); % Perform Log edge detection
subplot(3,3,8);
imshow(g); % Display image
title('Edge detection using zerocrossing');

% LINE DETECTION
clc;
clear all;
close all;
I =imread('C:\Users\VM5606\Desktop\light1.jpg'); % Read the image
I=rgb2gray(I); % RGB -> Gray scale conversion
BW = edge(I,'canny'); % Edge detection using canny
[H,T,R] = hough(BW); % Hough transform
P =houghpeaks(H,5,'threshold',ceil(0.3*max(H(:)))); % Detect Hough peaks
x = T(P(:,2)); y = R(P(:,1));
% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);
figure, imshow(I), hold on
max_len = 0;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% Plot beginnings and ends of lines
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
% Determine the endpoints of the longest line segment
len = norm(lines(k).point1 - lines(k).point2);
if ( len>max_len)
max_len = len;
xy_long = xy;
end
end
% Highlight the longest line segment
plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','blue');
legend('Line','startpoint','end point');
% POINT DETECTION ( Compatible in 2013 version )
clc;
clear all;
close all;
imgA=imread('C:\Users\VM5606\Desktop\light1.jpg'); % Read image
imgA=rgb2gray(imgA); % RGB -> Gray scale conversion
ptThresh = 0.1; % Setting threshold level
pointsA = detectFASTFeatures(imgA, 'MinContrast', ptThresh); % Detect points
figure; imshow(imgA); hold on; % Display result
plot(pointsA);
title('Detected points in A');

%% POINT DETECTION ( Compatible in 2007 version )


clc;
clear all;
close all;
Y = imread('C:\Users\VM5606\Desktop\light1.jpg');
Y1= bwareaopen(Y, 20);
fplap = [1 1 1; 1 -8 1; 1 1 1]; % Laplacian at a point
% fplap = [0 1 0; 1 -4 1; 0 1 0]; % Laplacian at a point
filtim = imfilter(Y,fplap,'symmetric', 'conv'); % Perform filtering by convolution
subplot(2,2,1)
imshow(Y);
title('Original');
subplot(2,2,2)
imshow(filtim);
title('Laplacian Point Filtered'); % Filtering of points
subplot(2,2,3)
imshow(Y-filtim);
title('Difference Image'); % Display the difference image

OUTPUT:
EDGE DETECTION

LINE DETECTION

POINT DETECTION
O/P for version 2013

O/P for version 2007

RESULT:
Thus the segmentation of an image by edge detection, line detection and point detection
techniques has been performed using MATLAB.

EX.NO: 10 BASIC MORPHOLOGICAL OPERATIONS


DATE:

AIM:
To perform morphological operations such as dilation, erosion, opening, closing, thinning and
thickening of images using MATLAB.

REQUIREMENTS:
PC with MATLAB software

ALGORITHM:
1) Read the image from file location.
2) Resize the image and set threshold level.
3) Convert the resized image into gray image for the threshold value.
4) Perform operations such as dilation, erosion, opening, closing, thinning and thickening in
the gray level image.
5) Display the result.

PROGRAM:
% MORPHOLOGICAL OPERATIONS
clc;
clear all;
close all;
thresh=120; % Threshold
filename= 'C:\Users\VM5606\Desktop\light1.jpg'; % The file to be read
i=imread(filename);
i=imresize(i, [256 256]); % Resize image
subplot(4,4,1);
imshow(i); % Display
title('Resized original image');
axis('square');
colormap('gray');

i1=uint8(i);
LEVEL=thresh/255.0;
i2= rgb2gray(i1);
BW = im2bw(i2,LEVEL); % Converts the intensity image I to black and white
subplot(4,4,2);
imshow(BW);
title('Gray image');

% Dilation
K3=ones(3); K5=ones(5); K7=ones(7); K9=ones(9);
B3=imdilate(BW,K3);
B5=imdilate(BW,K5);
B7=imdilate(BW,K7);
B9=imdilate(BW,K9);

subplot(4,4,3);
imshow(B3); % display
title('Dilated image to 3 pixels');
axis('square');
colormap('gray');
subplot(4,4,4);
imshow(B5); % display
title('Dilated image to 5 pixels');
axis('square');
colormap('gray');

subplot(4,4,5);
imshow(B7); % display
title('Dilated image to 7 pixels');
axis('square');
colormap('gray');

subplot(4,4,6);
imshow(B9); % display
title('Dilated image to 9 pixels');
axis('square');
colormap('gray');

% Erosion
K3=ones(3); K5=ones(5); K7=ones(7); K9=ones(9);
B3=imerode(BW,K3);
B5=imerode(BW,K5);
B7=imerode(BW,K7);
B9=imerode(BW,K9);

subplot(4,4,7);
imshow(B3); % display
title('Image erosed to 3 pixels');
axis('square');
colormap('gray');

subplot(4,4,8);
imshow(B5); % display
title('Image erosed to 5 pixels');
axis('square');
colormap('gray');

subplot(4,4,9);
imshow(B7); % display
title('Image erosed to 7 pixels');
axis('square');
colormap('gray');

subplot(4,4,10);
imshow(B9); % display
title('Image erosed to 9 pixels');
axis('square');
colormap('gray');

% Opening
op=bwmorph(BW,'open');
subplot(4,4,11);
imshow(op); % display
title('Opened image');
axis('square');
colormap('gray');

% Closing
op=bwmorph(BW,'close');
subplot(4,4,12);
imshow(op); % display
title('Closed image');
axis('square');
colormap('gray');

% Thinning
op=bwmorph(BW,'thin');
subplot(4,4,13);
imshow(op); % display
title('Thinned image');
axis('square');
colormap('gray');

% Thickening
op=bwmorph(BW,'thick');
subplot(4,4,14);
imshow(op); % display
title('Thickened image');
axis('square');
colormap('gray');

OUTPUT:
MORPHOLOGICAL PROCESSING

RESULT:
Thus the basic morphological operations such as dilation, erosion, opening, closing, thinning,
thickening of an image has been performed using MATLAB.

EX.NO: 11 REGION BASED SEGMENTATION


DATE:

AIM:
To perform Region based Segmentation on an image

ALGORITHM:

1. Load the given image


2. Display the Region of the loaded image
3. Enhance region growing of the loaded image
4. Display the Region growing image

PROGRAM:

function
J=regiongrowing(I,x,y,reg_maxdist) I
= im2double(imread('medtest.png'));
x=198; y=359;
J=
regiongrowing(I,x,y,0.2
); figure, imshow(I+J);
if(exist('reg_maxdist','var')==0), reg_maxdist=0.2; end
if(exist('y','var')==0)
figure
imshow(I,[]);
[y,x]=getpts;
y=round(y(1));
x=round(x(
1)); end
J = zeros(size(I)); % Output
Isizes = size(I); % Dimensions of input image
reg_mean = I(x,y); % The mean of the segmented region
reg_size = 1; % Number of pixels in region
neg_free = 10000;
neg_pos=0; neg_list =
zeros(neg_free,3);
pixdist=0;
neigb=[-1 0; 1 0; 0 -1;0 1];
while(pixdist<reg_maxdist&&reg_size<numel(I))
% Add new neighbors
pixels for j=1:4,
% Calculate the neighbour
coordinate xn = x +neigb(j,1); yn
= y +neigb(j,2);
% Check if neighbour is inside or outside the image
ins=(xn>=1)&&(yn>=1)&&(xn<=Isizes(1))&&(yn<=Isizes(2));
% Add neighbor if inside and not already part of the segmented area
if(ins&&(J(xn,yn)==0))
neg_pos = neg_pos+1;
neg_list(neg_pos,:) = [xn yn I(xn,yn)]; J(xn,yn)=1;
end dist = abs(neg_list(1:neg_pos,3)-
reg_mean); [pixdist, index] = min(dist);
J(x,y)=2; reg_size=reg_size+1;
% Calculate the new mean of the region
reg_mean= (reg_mean*reg_size + neg_list(index,3))/(reg_size+1);
% Save the x and y coordinates of the pixel (for the neighbour add
proccess) x = neg_list(index,1); y = neg_list(index,2);
% Remove the pixel from the neighbour (check) list
neg_list(index,:)=neg_list(neg_pos,:); neg_pos=neg_pos-1;
end
% Return the segmented area as logical
matrix J=J>1;
end

OUTPUT:
REGION GROWING

RESULT:
Thus the given input image executed and get region growing image successfully using
MATLAB Software.
EX.NO: 12 SEGMENTATION USING WATERSHED TRANSFORMATION
DATE:

AIM:
To perform watershed transform on an image

ALGORITHM:
1. Load the given image
Apply watershed transform
Display the resultant
images

PROGRAM:
clc;
x=checkerboard
(32);
subplot(2,2,1);
imshow(x);
title('given
image');
y=watershed(x,
4);
subplot(2,2,2);
imshow(y);
title('segmented image');
x1=imnoise(x,'salt&
pepper',0.1);
subplot(2,2,3),imshow(x1);
title('image added with
noise'); y1=watershed(x1,4);
subplot(2,2,4),imshow(y1);
title('segmented noisy-
image')

OUTPUT:

RESULT:
Watershed transform has been applied and studied on the given image
EX.NO: 13 ANALYSIS OF IMAGES WITH DIFFERENT COLOR MODELS
DATE:

AIM:
To analyze an image with different color models using MATLAB. Tasks to be performed
1) Conversion of an image to different color space
2) Detection of a color in RGB space.

REQUIREMENTS:
PC with MATLAB software.

ALGORITHM:
COLOR CONVERSION
1) Read the image from file location
2) Cast to double and display pixel information
3) Perform various color conversions in the image
4) Display the result

COLOR DETECTION
1) Read the image from file location
2) Split the original image into color bands
3) Set the threshold level for each color band and create a mask for the original image
4) Check whether are the masks combined become true
5) Obtain the red masked image with the specified threshold level
6) Display the result

PROGRAM:
% COLOR SPACE CONVERSION
clc;
clear all;
close all;
i1=imread('C:\Users\VM5606\Desktop\light1.jpg');
i1 = double(i1)/255; % Cast to double in the range [0,1]
subplot(3,3,1);
imshow(i1) % display
imtool(i1); % shows pixel information
title('Original image');
sz=size(i1);
i3 = rgb2gray(i1);
subplot(3,3,2);
imshow(i3);
title('RGB -> Gray');
i4 = rgb2ntsc(i1);
subplot(3,3,3);
imshow(i4);
title('RGB -> NTSC');
[X,map] = rgb2ind(i1,128);
subplot(3,3,4);
image(X);
colormap(map);
title('RGB -> Index');
axis off
axis image
i5 = ind2gray(X,map);
subplot(3,3,5);
imshow(i5);
title('Index -> Gray');
i6= ntsc2rgb(i4);
subplot(3,3,6);
imshow(i6);
title('NTSC -> RGB');

% COLOR DETECTION IN RGB COLOR SPACE


clc;
close all;

% Read standard image


im = imread('C:\Users\VM5606\Desktop\light1.jpg');

% Display the original image.


subplot(3, 4, 1);
imshow(im);
title('Original RGB Image');

% Maximize figure.
set(gcf, 'Position', get(0, 'ScreenSize'));

% Split the original image into color bands.


redBand = im(:,:, 1);
greenBand = im(:,:, 2);
blueBand = im(:,:, 3);

% Display them.
subplot(3, 4, 2);
imshow(redBand);
title('Red band');
subplot(3, 4, 3);
imshow(greenBand);
title('Green band');
subplot(3, 4, 4);
imshow(blueBand);
title('Blue Band');

% Threshold each color band.


redThreshold = 95;
greenThreshold = 85;
blueThreshold = 90;
redMask = (redBand > redThreshold); % for redmask, make redband greater than redThreshold
greenMask = (greenBand < greenThreshold); % for greenmask, make greenband greater than
greenThreshold
blueMask = (blueBand < blueThreshold); % for bluemask, make blueband greater than
blueThreshold

% Display them.
subplot(3, 4, 6);
imshow(redMask, []);
title('Red Mask');
subplot(3, 4, 7);
imshow(greenMask, []);
title('Green Mask');
subplot(3, 4, 8);
imshow(blueMask, []);
title('Blue Mask');

% Combine the masks to find where all 3 are "true."


redObjectsMask = uint8(redMask & greenMask & blueMask);
subplot(3, 4, 10);
imshow(redObjectsMask, []);
title('Red Objects Mask');
maskedrgbImage = uint8(zeros(size(redObjectsMask))); % Initialize
maskedrgbImage(:,:,1) = im(:,:,1) .* redObjectsMask;
maskedrgbImage(:,:,2) = im(:,:,2) .* redObjectsMask;
maskedrgbImage(:,:,3) = im(:,:,3) .* redObjectsMask;
subplot(3, 4, 11);
imshow(maskedrgbImage);
title('Masked Original Image');

OUTPUT:

COLOR CONVERSION
PIXEL INFORMATION

COLOR DETECTION

RESULT:
` Thus analysis of images by color space conversion and color detection has been
performed using MATLAB.
EX.NO: 14 STUDY OF DICOMM STANDARDS
DATE:

AIM:
To study about DICOMM standards.

DESCRIPTION:

DICOM stands for Digital Imaging and Communications in Medicine. DICOM is a


standard that establishes rules that allow medical images and associated information to be
exchanged between imaging equipment from different vendors, computers, and hospitals.
A computed tomography (CT) scanner produced by vendor A and a magnetic resonance imaging
(MRI) scanner produced by vendor B can send images to a PACS from vendor C using DICOM as
a common language. In addition to storing image information, other DICOM standard services
include query/retrieve, print management, scheduling of acquisition and notification of completion,
and security profiles.

Digital exchange of retinal images and DICOM


DICOM stands for Digital Imaging and Communications in Medicine and is an
organization founded in 1983 to create a standard method for the transmission of medical images
and their associated information across all fields of medicine. For ophthalmology, Working Group
9 (WG-9) of DICOM is a formal part of the American Academy of Ophthalmology. Until recently,
the work of WG-9 has focused on creating standards for fundus, anterior-segment, and
external ophthalmic photography, resulting in DICOM Supplement 91 Ophthalmic Photography
Image SOP Classes, and on OCT imaging in DICOM Supplement 110:
Ophthalmic Tomography Image Storage SOP

DICOM standards build as much as possible upon other standards. For example, DICOM
does not prescribe an image compression standard. Images stored as DICOM images can contain
the actual image data. A typical example of this is a JPEG image. DICOM 91 and 110 standardize
how metadata for an image, such as patient and visit data, acquisition modes and camera settings,
compression settings and data formats, and clinical interpretation, is stored as an integral part of the
image.

Digital imaging and communications in medicine


DICOM is an internationally agreed standard for all medical imaging modalities. The
standard was initiated in response to the development of computer-aided imaging in the 1970s by a
joint committee from the American College of Radiology (ACR) and the National Electrical
Manufacturers Association (NEMA). They first published an ACR-NEMA standard in 1985 and
updated it in 1988. Version 3 saw the name changed to DICOM and was published in 1993. The
standard now covers all kinds of medical images but also includes other data such as patient name,
reference number, study number, dates and reports. Most manufacturers adhere to the standard and
data transfer problems are much less likely to occur than was previously the case.
The DICOM standard (ISO 12052) enables the transfer of medical images to and from software
and scanners from different manufacturers and aided the development of picture archiving and
communication systems, which can be incorporated with larger medical information or records
systems.

RESULT:
Thus DICOMM standard was studied.
EX.NO: 15 IMAGE COMPRESSION TECHNIQUES
DATE:

AIM
To implement an image Compression program using MATLAB.

ALGORITHM

1) Read the image from file location


2) Perform the image and run the code
3) Display the compression image

clearall;
closeall;
input_image1=imread('heart.jpg');
input_image=imnoise(input_image1,'speckle',.01);
figure;
imshow(input_image);
n=input('enter the decomposition level=');
[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('haar');
[c,s] =
wavedec2(input_image,n,Lo_D,Hi_D);
disp('the decomposition vector output is');
disp(c);
[thr,nkeep] = wdcbm2(c,s,1.5,3*prod(s(1,:)));
[Compressed_image,TREE,Comp_ratio,PERFL2]=wpdencmp(thr,'s',n,'haar','threshold',5,1);
disp('Compression ratio in %');
disp(Comp_ratio);
re_ima1 =
waverec2(c,s,'haar'); re_ima =
uint8(re_ima1); subplot(1,3,1);
imshow(input_image);
title('I/P image');
subplot(1,3,2);
imshow(Compressed_image);
title('Compressed_image');
subplot(1,3,3);
imshow(re_ima);
title('reconstructed image');

OUTPUT
COMPRESSED IMAGE

RESULT:
Thus the given input image executed and get compressed image successfully using MATLAB
Software.
EX.NO: 16 IMAGE RESTORATION
DATE:

AIM
To implement an image restoration program using MATLAB.

ALGORITHM

 Read the image from file location


 Perform the image and run the code
 Display the restoration image

PROGRAM

l=im2double(imread('heart.jpg'));
LEN=60;
THETA=0;
noise_var=0.001;
est_nsr=noise_var/var(l(:));
PSF=fspecial('motion',LEN,THE
TA);
wnr=deconvwnr(l,PSF,est_nsr);
imshow(wnr);

OUTPUT:

ORIGINAL IMGAE:

RESULT:
Thus the given input image executed and get restoration image successfully using MATLAB
Software.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy