Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

BM3652 Mip

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 63

BM3652 MEDICAL IMAGE PROCESSING LAB

GANESH COLLEGE OF ENGINEERING


Department of Biomedical Engineering

Laboratory Manual
Regulation : 2021

Academic year : 2023-2024

Programme / Department : B.E / BME

Year / Semester : III / VI

Subject Code : BM3652

Subject Name : MEDICAL IMAGE PROCESSING


LABORATORY
STAFF INCHARGE : B.VINOD,B.E.,M.E.,(Ph.D)

1
BM3652 MEDICAL IMAGE PROCESSING LAB

LIST OF EXPERIMENTS

EX.NO EXPERIMENT NAME Mark Sign


1

10

11

12

13

14

15

16

2
BM3652 MEDICAL IMAGE PROCESSING LAB

EX.NO:1 IMAGE SAMPLING AND


QUANTIZATION DATE:

AIM:
To apply sampling and quantization to an image using MATLAB.

THEORY:

Image Sampling
A continuous image f(x,y) is normally approximated by equally spaced samples
arranged in the form of an N x M array where each element of the array is a discrete quantity.

The sampling rate (or pixel clock) of the digitizer determines the spatial resolution of
the digitized image.
The finer the sampling (i.e., the larger M and N) the better the approximation of the
continuous image function f(x,y).

Image Quantization
A magnitude of the sampled image is expressed as a digital value in image processing.
The transition between continuous values of the image function (brightness) and its digital
equivalent is called quantitation. The number of quantitation levels should be high enough for
human perception of fine shading details in the image. The occurrence of false contours is the
main problem in image which has been quantized with insufficient brightness levels. This
effect arises when the number of brightness levels is lower than that which humans can easily
distinguish. This number is dependent on many factors -- for example, the average local
brightness -- but displays which avoid this effect will normally provide a range of at least 100
intensity levels.
Most digital image processing devices use quantitation into k equal intervals. If b bits
are used ... the number of brightness levels is k=2^b. Eight bits per pixel are commonly used,
specialized measuring devices use 12 and more bits per pixel.

3
BM3652 MEDICAL IMAGE PROCESSING LAB

OUTPUT:

4
BM3652 MEDICAL IMAGE PROCESSING LAB

PROGRAM:
a=imread("1.jpg");
subplot(2,2,1);
imshow(a);
title('Original');
x= a(1:5:end, 1:5:end);
[im_q] = quantize(x)
subplot(2,2,2);
imshow (x);
title('sampled (5)');
y= a(1:10:end, 1:10:end);
[im_q] = quantize(y);
subplot(2,2,3);
imshow (y);
title('sampled (10)');
z= a(1:15:end, 1:15:end);
[im_q] = quantize(z);
subplot(2,2,4);
imshow (z);
title('sampled (15)');

RESULT:
Thus using MATLAB image sampling and quantization parameter of the medical image is displayed.
5
BM3652 MEDICAL IMAGE PROCESSING LAB

OUTPUT:

Intensity resolution

Spatial resolution

6
BM3652 MEDICAL IMAGE PROCESSING LAB

EX.NO:2 ANALYSIS OF SPATIAL AND INTENSITY RESOLUTION OF IMAGES


DATE:

AIM:
To analyze spatial and intensity resolution of images using MATLAB.

DESCRIPTION:

J = imadjust(I) maps the intensity values in grayscale image I to new values in J such that 1%
of data is saturated at low and high intensities of I. This increases the contrast of the output
image J. This syntax is equivalent to imadjust(I,stretchlim(I)).
RGB2 = imadjust(RGB1, ) performs the adjustment on each plane (red, green, and blue) of
the RGB image RGB1. If low_in, high_in, low_out, high_out, and gamma are scalars, imadjust
applies the same mapping to the red, green, and blue components of the image. To specify
unique mappings for each color component of the image, specify low_in, high_in, low_out,
high_out, and gamma as 1-by-3 vectors.

PROGRAM:
%Intensity resolution
I = imread('2.jpg');
subplot(2,2,1);
imshow(I);
J = imadjust(I);
subplot(2,2,2);
imshow(J)
RGB = imread('2.jpg');
subplot(2,2,3);
imshow(RGB)
RGB2 = imadjust(RGB,[.2 .3 0; .6 .7 1],[]);
subplot(2,2,4);
imshow(RGB2)

%Spatial resolution

I = imread("2.2.jpg");
J = imresize(I, 0.5);
subplot(1,2,1),
imshow(I);
title('original image');
subplot(1,2,2);
imshow(J);
title('resized image');

RESULT:
7
BM3652 MEDICAL IMAGE PROCESSING LAB
Thus the spatial and intensity resolution of images using MATLAB is analyzed.

EX.NO:3 INTENSITY TRANSFORMATION OF IMAGES


DATE

AIM:
To transform the intensity of images using MATLAB.

THEORY:

Intensity transformation involves contrast manipulation and thresholding. An application of


intensity transformation is to increase the contrast between certain intensity values so that we
can the information that we seek is more visible and clear. Making changes in the intensity is
done through Intensity Transformation Functions.

The four main intensity transformation functions are:

 Photographic Negative
 Gamma Transformation
 Logarithmic Transformation
 Contrast-stretching Transformation

Photographic negative
imcomplement - true black become true white and vice versa. It is suitable when the black
areas are dominant in size.
Gamma Transformation

Values for low_in, high_in, low_out, and high_out must be between 0 and 1. Values below
low_in are clipped to low_out and values above high_in are clipped to high_out. For the
example below, we will use empty matrix ([]) to specify the default of [0 1]. Gamma specifies
the shape of the curve describing the relationship between the values in J and f. If gamma is
less than 1, the mapping is weighted toward higher (brighter) output values. If gamma is greater
than 1, the mapping is weighted toward lower (darker) output values. By default, gamma is set
to 1 (linear mapping).

Logarithmic Transformation
To use Logarithmic Transformation, use the function c*log(1+f).This transformation
enhances the details (or contrast) in the darker region of an image (with lower intensity values)
by expensing detail in brighter regions. In other words, it expands the values of dark pixel in an
image while compressing the higher level values. The syntax of this function is
g = c*log(1+double(f))
The higher the c, the brighter the image will appear. Any values (produced from logarithmic
transformation) greater than one, are displayed as full intensity, equivalent to the value of 1.
Below are the codes that implements logarithmic transformation and example of
8
BM3652 MEDICAL IMAGE PROCESSING LAB
logarithmic transformation images.

9
BM3652 MEDICAL IMAGE PROCESSING LAB

OUTPUT:

10
BM3652 MEDICAL IMAGE PROCESSING LAB

Contrast-Stretching Transformation
Contrast-Stretching Transformation (also called Piecewise-Linear Transformation)
stretches gray-level ranges where we desire more information. This transformation increases
the contrast between the darks and the lights. In simple words, the dark becomes darker and the
light becomes brighter. To use this transformation, we use the function as below:
g = (1./(1+(m./(double(f)+eps)).^ E)

PROGRAM:
I = imread("3.jpg");
subplot(5,3,1),
imshow(I);
J=imcomplement(I);
subplot(5,3,2);
imshow(J)
J1 = imadjust(I,[],[],3);
J2 = imadjust(I,[],[],1);
J3 = imadjust(I,[],[],0.4);
subplot(5,3,3),imshow(J1);
subplot(5,3,4), imshow(J2);
subplot(5,3,5),imshow(J3);
I2 = im2double(I);
J4 = 1 * log(1 + I2); J5 = 2 * log(1 + I2); J6 = 5 * log(1 + I2);
subplot(5,3,6),imshow(J4)
subplot(5,3,7),
imshow(J5)
subplot(5,3,8),
imshow(J6)
I2=im2double(I);
m=mean2(I2)
contrast1 = 1./(1 + (m ./(I2 + eps )).^4);
contrast2 = 1./(1 + (m ./(I2 + eps )).^5);
contrast3 = 1./(1 + (m ./(I2 + eps )).^10);
contrast4 = 1./(1 + (m ./(I2 + eps )).^-5);
contrast5 = 1./(1 + (m ./(I2 + eps )).^-1);
subplot(5,3,9), imshow(I2)
subplot(5,3,10), imshow(contrast1)
subplot(5,3,11),
imshow(contrast2)
subplot(5,3,12),
imshow(contrast3)
subplot(5,3,13),
imshow(contrast4)
subplot(5,3,14),
imshow(contrast5)

RESULT:
Thus the intensity of image is transformed using MATLAB

11
BM3652 MEDICAL IMAGE PROCESSING LAB

EX.NO:4 DFT ANALYSIS OF IMAGES


DATE:

AIM:
To apply, study and demonstrate for two dimension discrete fourier transform of image.

SYNTAX

fft
Y= fft(X)
Y= fft(X,n)
Y= fft(X, [], dim)
Y= fft(X,n,dim)

fftshift
Y=fftshift(X)
Y=fftshift(X, dim)

ifft
Y=ifft(X)
Y=ifft(X,n)
Y=ifft(X,[],dim)
Y=ifft(X,n,dim)
Y=ifft(………,’symmetric’)
Y=ifft(…….,’nonsymmetric’)

ifftshift
ifftshift(X)
ifftshift(X,dim)

DESCRIPTION

fft:
The function Y=fft(X) and Y=ifft(X) implement the transform and inverse transform
pair give for vectors of length N by
X (k) = ∑𝑁 𝑋(𝑗)𝑤 (j-1)(k-1)
𝑗=1 N
X
∑𝑁(j) = (1/N) 𝑋(𝑘)𝑤 –(j-1)(k-1)
𝑘=1 N

where
𝑤N= e (-2πi)/Nis an Nth toot of unity

fftshift
Y=fftshift(X) rearranges the output of fft, fft2 and fftn by moving the zero- frequency component to
the center of the array.
It is useful for visualizing a fourier transform with the zero- frequency component in the
middle of the spectrum
For vector, fftshift(X) swaps the left and right hvalues of X. For matrices, fftshift(X)
12
BM3652 MEDICAL IMAGE PROCESSING LAB
swaps the first quadrant with the 3rd and 2nd quadrant with the 4th .

13
BM3652 MEDICAL IMAGE PROCESSING LAB

OUTPUT:

14
BM3652 MEDICAL IMAGE PROCESSING LAB

ifft:
Y= ifft(X) returns the inverse discrete fourier transform (DFT) of vector X, computed
with a fast fourier transform (FFT) algorithm. If X is a matrix, ifft returns the inverse DFT
of each column of the matrix.

ifftshift:
ifftshift(X) swaps the left and right values of the vector X. For matrices,
ifftshift(X) swaps the first quadrant with the third and the second quadrant with the fourth.
If X is a multidimensional array, ifftshift(X) swaps “half-spaces” of X along each
dimensions.
ifftshift (X,dim) applies the ifftshift operation along the dimension dim.

PROGRAM:
clc; clear all;
close all;
a= zeros(200,256);
a(100:150,10:150)=1;
subplot(2,3,1);
imshow(a);
b=fft2(a);
subplot(2,3,2);
imshow(b);
c=fftshift(b);
subplot(2,3,3);
imshow(c);
d=ifftshift(c);
subplot(2,3,4);
imshow(d);
e=ifft2(d);
subplot(2,3,5);
imshow(e);

RESULT:
Thus the 2D DFT is applied, studied and demonstrated.
15
BM3652 MEDICAL IMAGE PROCESSING LAB

output:

16
BM3652 MEDICAL IMAGE PROCESSING LAB

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


DATE

AIM:
To apply Walsh, Hadamard, DCT and Haar transform on an image using MATLAB.

THEORY:

Walsh-Hadamard:

The Hadamard transform (also known as the Walsh–Hadamard transform, Hadamard–


Rademacher–Walsh transform, Walsh transform, or Walsh–Fourier transform) is an example of
a generalized class of Fourier transforms. It performs an orthogonal, symmetric, involutive,
linear operation on 2m real numbers (or complex numbers, although the Hadamard matrices
themselves are purely real).
The Hadamard transform can be regarded as being built out of size-2 discrete Fourier
transforms (DFTs), and is in fact equivalent to a multidimensional DFT of size 2 × 2 × ⋯× 2 ×
2.It decomposes an arbitrary input vector into a superposition of Walsh functions.
DCT
The DCT equation computes the i, j th entry of the DCT of an image. A discrete cosine
transform (DCT) expresses a finite sequence of data points in terms of a sum of cosine
functions oscillating at different frequencies. DCTs are important to numerous applications in
science and engineering, from lossy compression of audio (e.g. MP3) and images (e.g. JPEG)
(where small high-frequency components can be discarded), to spectral methods for the
numerical solution of partial differential equations. The use of cosine rather than sine functions
is critical for compression, since it turns out (as described below) that fewer cosine functions
are needed to approximate a typical signal, whereas for differential equations the cosines
express a particular choice of boundary conditions.
In particular, a DCT is a Fourier-related transform similar to the discrete Fourier
17
BM3652 MEDICAL IMAGE PROCESSING LAB
transform (DFT), but using only real numbers. DCTs are equivalent to DFTs of roughly twice
the length, operating on real data with even symmetry (since the Fourier transform of a real and
even function is real and even), where in some variants the input and/or output data are shifted
by half a sample. There are eight standard DCT variants, of which four are common. The most
common variant of discrete cosine transform is the type-II DCT, which is often called simply
"the DCT". Its inverse, the type-III DCT, is correspondingly often called simply "the inverse
DCT" or "the IDCT". Two related transforms are the discrete sine transform (DST), which is
equivalent to a DFT of real and odd functions, and the modified discrete cosine transform
(MDCT), which is based on a DCT of overlapping data.

18
BM3652 MEDICAL IMAGE PROCESSING LAB

DCT

19
BM3652 MEDICAL IMAGE PROCESSING LAB

PROGRAM:
%WALSH HADAMARD
x1 = ecg(512); % Single ecg wave
x = repmat(x1,1,8);
x = x + 0.1.*randn(1,length(x)); % Noisy ecg signal
y = fwht(x); % Fast Walsh-Hadamard transform
figure('Color','white');
subplot(2,1,1);
plot(x);
xlabel('Sample index');
ylabel('Amplitude');
title('ECG Signal'c);
subplot(2,1,2);
plot(abs(y))
xlabel('Sequency index');
ylabel('Magnitude');
title('WHT Coefficients');
y(1025:length(x)) = 0; % Zeroing out the higher coefficients
xHat = ifwht(y); % Signal reconstruction using inverse WHT
figure('Color','white');
plot(x);
hold on
plot(xHat,'r');
xlabel('Sample index');
ylabel('ECG signal amplitude'); legend('Original
Signal','Reconstructed Signal');

% DCT
RGB = imread("52.jfif");
I = rgb2gray(RGB);
subplot(2,2,1);
imshow(RGB);
title('Original');
subplot(2,2,2);
imshow(I);
title('Grayscale');
J = dct2(I);
subplot(2,2,3);
imshow(J);
title('DCT');
k = idct2(J);
subplot(2,2,4);
imshow(k,[0,255]);
title('IDCT');

RESULT:
Thus the Walsh, Hadamard, DCT and Haar transform is applied on an image using
MATLAB.

20
BM3652 MEDICAL IMAGE PROCESSING LAB

EX.NO:6 HISTOGRAM PROCESSING


DATE

AIM:
To perform Histogram operation on image using MATLAB.

SYNTAX
J = histeq(I, hgram)
J = histeq(I, n)
[J, T] = histeq(I,...)
newmap = histeq(X, map, hgram)
newmap = histeq(X, map)
[newmap, T] = histeq(X,...)
imhist[I]
imhist(I,n)
imhist (X,map)
[counts,X]= imhist(……)
imhist(I) displays a histogram for the image I above a grayscale colorbar
imhist(I,n) displays a histogram where n specifies the number of bins used in the
histogram
imhist(X,map) displays a histogram for the indexed image X.

Theory
histeqenhances the contrast of images by transforming the values in an intensity image,
or the values in the colormap of an indexed image, so that the histogram of the output image
approximately matches a specified histogram.
J = histeq(I, hgram) transforms the intensity image I so that the histogram of the
output intensity image J with length(hgram) bins approximately matches hgram.
histeq automatically scales hgram so that sum(hgram) = prod(size(I)). The histogram of J will
better match hgram when length(hgram) is much smaller than the number of discrete levels in
I.
J = histeq(I, n) transforms the intensity image I, returning in J an intensity image with
n discrete gray levels. A roughly equal number of pixels is mapped to each of the n levels in J,
so that the histogram of J is approximately flat. (The histogram of J is flatter when n is much
smaller than the number of discrete levels in I.) The default value for n is 64.
[J, T] = histeq(I,...) returns the grayscale transformation that maps gray levels in the
image I to gray levels in J.
newmap = histeq(X, map, hgram) transforms the colormap associated with the
indexed image X so that the histogram of the gray component of the indexed image
(X,newmap) approximately matches hgram. The histeq function returns the transformed
colormap in newmap. length(hgram) must be the same as size(map,1).
newmap = histeq(X, map) transforms the values in the colormap so that the histogram
of the gray component of the indexed image X is approximately flat. It returns the transformed
colormap in newmap.
[newmap, T] = histeq(X,...) returns the grayscale transformation T that maps the gray
component of map to the gray component of newmap.
[counts, X]=imhist (….) returns the histogram counts in counts and the bin location in
X so that stem (X, counts) shows the histogram.

21
BM3652 MEDICAL IMAGE PROCESSING LAB

OUTPUT:

22
BM3652 MEDICAL IMAGE PROCESSING LAB

PROGRAM:

clc; clear all;


close all;
A= imread("6.png");
subplot(2,2,1);
imshow(A);
title('Original Image');
subplot(2,2,2);
imhist(A);
title('Histogram of original image');
ylim('auto');
s=histeq(A);
subplot(2,2,3);
imshow(s);
title('Histogram Equalized Image');
subplot(2,2,4);
imhist(s);
title('Histogram of Equalized Image');

RESULT
Thus the histogram processing is performed on image is displayed using MATLAB.

23
BM3652 MEDICAL IMAGE PROCESSING LAB

EX.NO:7 IMAGE ENHANCEMENT-SPATIAL FILTERING


DATE

AIM:
To apply spatial non-linear filter for noise images using MATLAB.
SYNTAX
J= imnise (I,type)
J= imnoise
(I,type,parameters) J=imnoise
(I, ‘gaussian’, m,v) J=imnoise
(I, ‘localwar’, v)
J=imnoise(I,’localwar’, image intensity, var)
J=imnoise(I,’poison’)
J=imnoise(I,’salt&pepper’,d)
J=imnoise(I,’speckle’, v)

DESCRIPTION

J= imnoise (I,type) adds noise of a given type to the intensity image I. is a string that
can have one of these value.
J= imnoise (I,type,parameters) depending on type, you can specify additional
parameters to imnoise.
J=imnoise (I, ‘gaussian’, m,v) adds guassion white noise of mean m and variance v to
the image I. The default is zero mean noise with 0.01 variance.
J=imnoise (I, ‘localwar’, v) adds zero mean, guassian white noise of local variance v
to the image I. V is an array of the same size as I.
J=imnoise(I,’localwar’, image intensity, var) adds zero-mean, guassian noise to an
image I, where the local variance of the noise, var is a function of the image Intensity value in
I.
J=imnoise(I,’poison’) generates poisson noise from the data instead of adding artificial
noise of the data.
J=imnoise(I,’salt&pepper’,d) adds salt and pepper noise to the image I, where d is the
noise density.
J=imnoise(I,’speckle’, v) adds multiplicative noise to the image I, using the equation
J=I+n*I, where n is uniformly distributed random noise with mean 0 and variance. The default
for v is 0.04.

24
BM3652 MEDICAL IMAGE PROCESSING LAB

OUTPUT:

25
BM3652 MEDICAL IMAGE PROCESSING LAB

PROGRAM:

clc;
clear all;
close all;
I = imread("7.jfif");
a=rgb2gray(I);
J = imnoise(a,'salt & pepper',0.02);
c=imnoise(a,'speckle');
d=imnoise(a,'gaussian');
e=medfilt2(J);
f=medfilt2(c);
g=medfilt2(d);
subplot(3,3,1),
imshow(a);
title('Original image');
subplot(3,3,2),
imshow(J);
title('Salt & pepper image');
subplot(3,3,3),
imshow(c);
title('Speckle image');
subplot(3,3,4),
imshow(d);
title('Gaussian image');
subplot(3,3,5),
imshow(e);
title('median filter on salt & pepper image');
subplot(3,3,6),
imshow(f);
title('median filter on speckle image');
subplot(3,3,7),
imshow(g);
title('median filter on Gaussian image');

RESULT
Thus applying filter for noise images using nonlinear spatial filtering techniques is used
and noise is reduced.
26
BM3652 MEDICAL IMAGE PROCESSING LAB

EX.NO:8 IMAGE ENHANCEMENT- FILTERING IN FREQUENCY DOMAIN


DATE

AIM:
To study the following filtering in frequency domain using MATLAB.

DESCRIPTION:
Ideal lowpass filter is the simplest lowpass filter. It “cut off’ all the high frequency
components of the fourier transform which are located at a distance greater than the specified
distance D0 from the origin of the centered transform.

Ideal low pass filter (ILPF)


TRANSFER FUNCTION
The transfer function of two- dimension ILPF is given
by, H(u,v) = { 1 if D(u,v)≤D0
0 if D(u,v)>D0
Where, D0– specified positive quantity
D(u,v) – Distance between the point (u,v) and the origin of the frequency
rectangle.
Distance (u,v) :
The distance from any point (u,v) to the center of the frequency rectangle is given by
D(u,v) = √(u2 + v2)
If the image size is MxN,
Center of the frequency rectangular is at (u,v) = (M/2, N/2)
Now the distance from any point (u,v) to the center or origin of the fourier transform is
D(u,v) = √ ( (u-M/2)2 + (v-N/2)2)
Butterworth Lowpass filter (BLPF)
In butterworthlowpass filter, there is no clear cutoff frequency which decides the
amount of frequencies to be passes and the amount of frequencies to be filtered.
When the amount of high frequency content removed decreases, the image becomes
finer in texture.
Transfer Function:
The transfer function of a BLPF with cutoff frequency at a distance D0 from the origin
is given by
H(u,v) =1/ (1+[D(u,v)/D0]2n)
Where n – filter order
D(u,v) = √((u-M/2)2+ (v-N/2)2)
Where D(u,v) =D0
H(u,v) = 1/ 1+(1)2n = 0.5 = 50%
Gaussian Low pass filter (GLPF)
Transfer Function:
The transfer function of two-dimensional GLPF is given by,
-D2(u,v)/2 2
H(u,v)= e 𝜎
Where 𝜎- measure of the Gaussian curve spread
D(u,v) = √ ((u-/2)2(v-N/2)2)
D(u,v) = H(u,v) = e-D2(u,v)/2D02
Where D0 cutoff frequency

27
BM3652 MEDICAL IMAGE PROCESSING LAB

OUTPUT

HIGHPASS

LOWPASS

28
BM3652 MEDICAL IMAGE PROCESSING LAB

PROGRAM:

%High pass filter

clc;
clear all;
close all;
a=imread("8.1.jpg");
p=rgb2gray(a);
[m,n]= size(p);
mask=ones(m,n);
for i = 150:180
for j = 210:240
mask(i,j)=0;
end
end
c=fft2(p);
d=fftshift(mask);
e=c.*d;
f=abs(ifft2(e));
subplot(2,2,1);
imshow(p);
title('original image');
subplot(2,2,2), imshow(mat2gray(f)),title('High pass filtered image');
subplot(2,2,3);
imshow(mask);
title('high pass filtered mask&#39');
subplot(2,2,4);
imshow(d);
title('mask after fftshift operation');

%Low pass filter

clc;
clear all;
close all;
b=imread('8.jfif');
a=rgb2gray(b);
[m,n]= size(a);
mask=zeros(m,n);
for i = 150:180
for j = 210:240 mask(i,j)=1;
end
end
c=fft2(a);
d=fftshift(mask);
e=c.*d; f=abs(ifft2(e));
subplot(2,2,1);
imshow(a); title('original image');
29
BM3652 MEDICAL IMAGE PROCESSING LAB
subplot(2,2,2),
imshow(mat2gray(f)),

BANDPASS

BANDSTOP

30
BM3652 MEDICAL IMAGE PROCESSING LAB

title('Low pass filtered image');


subplot(2,2,3);
imshow(mask);
title('Low pass filtered mask');
subplot(2,2,4);
imshow(d);
title('mask after fftshift operation');
I=I(125+[1:125],1:256,:);

31
BM3652 MEDICAL IMAGE PROCESSING LAB

%Band pass filter

clc;
clear all;
close all;
p=imread('2.2.jpg');
a=rgb2gray(p)
[m,n]=size(a);
mask=zeros(m,n);
for i=130:220
for j=200:300
mask (i,j)=1;
end
end
for i=150:190
for j=230:270
mask(i,j)=0;
end
end
b=fftshift(mask);
imshow(mask);
b=fft2(a);
c=fftshift (mask);
d=b.*c;
e=abs(ifft2(d));
subplot(2,2,1);
imshow(a);
title('original siganl');
subplot(2,2,2);
imshow(mat2gray(e));
title('band pass filtered image');
subplot(2,2,3);
imshow(mask);
title('band pass filter mask');
subplot(2,2,4);
imshow(c);
title('mask after fft shift operation');

%Bandstop

clc;
clear all;
close all;
s=imread('cells.jpg');
a=rgb2gray(s);
[m,n]=size(a);

32
BM3652 MEDICAL IMAGE PROCESSING LAB
mask=ones(m,n);
for i=130:200
for j=210:280
mask (i,j)=0;
end
end
for i=150:175
for j=225:260
mask(i,j)=1;
end
end
b=fftshift(mask);
imshow(mask);
b=fft2(a);
c=fftshift (mask);
d=b.*c;
e=abs(ifft2(d));
subplot(2,2,1);
imshow(a);
title('original siganl');
subplot(2,2,2);
imshow(mat2gray(e));
title('band stop filtered image');
subplot(2,2,3);
imshow(mask);
title('band stop filter mask');
subplot(2,2,4);
imshow(c);
title('mask after fft shift operation');

Result:
Thus the MATLAB program to perform filtering in frequency domain is explained

EX.NO:09 IMAGE SEGMENTATION – EDGE, LINEAND POINT DETECTION


DATE

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

SYNTAX:

33
BM3652 MEDICAL IMAGE PROCESSING LAB

BW= edge(I)
BW= edge (I, ‘sobel’)
BW= edge (I, ‘prewith’)
BW= edge (I, ‘roberts’)
BW= edge (I, ‘log’)
BW= edge (I, ‘canny’)

THEORY
Edges characterize boundaries and are therefore a problem of fundamental importance
in image processing. Edges in images are areas with strong intensity contrasts – a jump in
intensity from one pixel to the next. Edge detecting an image significantly reduces the amount
of data and filters out useless information, while preserving the important structural properties
in an image. There are many ways to perform edge detection. However, the majority of
different methods may be grouped into two categories, gradient and Laplacian. The gradient
method detects the edges by looking for the maximum and minimum in the first derivative of
the image. The Laplacian method searches for zero crossings in the second derivative of the
image to find edges. An edge has the one-dimensional shape of a ramp and calculating the
derivative of the image can highlight its location. Suppose we have the following signal, with
an edge shown by the jump in intensity below: The intensity changes thus discovered in each
of the channels are then represented by oriented primitives called zero-crossing segments, and
evidence is given that this representation is complete. (2) Intensity changes in images arise
from surface discontinuities or from reflectance or illumination boundaries, and these all have
the property that they are spatially localized. Because of this, the zero-crossing segments from
the different channels are not independent, and rules are deduced for combining them into a
description of the image. This description is called the raw primal sketch.

Point Detection:
The detection of isolate points embedded in constant or nearly constant areas is detected as:

Fig1: A mask for point detection


where T is a nonnegative threshold. Point detection is implemented in matlab using
function imfilter. If T is given, the following command implements the point detection
approach:
g=abs(imfilter(double(f),w)) >=T;

34
BM3652 MEDICAL IMAGE PROCESSING LAB

OUTPUT:

POINT

LINE

35
BM3652 MEDICAL IMAGE PROCESSING LAB

where f is the input image, w is an appropriate point-detection mask, and g is the resulting
image.
Line Detection:
The next level of complexity is to try to detect lines. Masks for lines of different directions:

Fig2: Line detection masks


Edge Detection:
Edge takes an intensity or a binary image f as its input, and returns a binary image g of
the same size as f, with 1's where the function finds edges in f and 0's elsewhere.
Edge supports six different edge-finding methods:
The Sobel Finds edges using the Sobel approximation to the derivative.
It returns edges at those points where the gradient of I is maximum.
The Prewitt Finds edges using the Prewitt approximation to the derivative.
It returns edges at those points where the gradient of I is maximum.
The Roberts Finds edges using the Roberts approximation to the derivative.
It returns edges at those points where the gradient of I is maximum.
The Laplacian of Gaussian Finds edges by looking for zero crossings after filtering I with a Laplacian
of Gaussian filter.
The zero-cross Finds edges by looking for zero crossings after filtering I with a filter you
specify.
The Canny Finds edges by looking for local maxima of the gradient of I. The gradient
is calculated using the derivative of a Gaussian filter. The method uses two
thresholds, to detect strong and weak edges, and includes the weak edges in
the output only if they are connected to strong edges. This method is
therefore less likely than the others to be "fooled" by noise, and more
likely to detect true weak edges.

The most powerful edge-detection method that edge provides is the Canny method.
36
BM3652 MEDICAL IMAGE PROCESSING LAB

EDGE

37
BM3652 MEDICAL IMAGE PROCESSING LAB

PROGRAM:
%Point detection
clc;
clear all;
close all;
f=imread("9.1.jpg");
w=[-1,-1,-1;-1,8,-1;-1,-1,-1];
g=abs(imfilter(double(f),w));
t=max(g(:));
g=g>=t;
subplot(121);
imshow(f),title('original image');
subplot(122),imshow("gl_port.bmp");
title('result of point detection');

%Line detection
i=imread("9.2jpg");
subplot(1,3,1);
imshow(i);
title('original image');
rotl=imrotate(i,33,'crop');
subplot(1,3,2);imshow(rotl);
title('rotated image');
bw=edge(rotl,'canny');
subplot(1,3,3);
imshow(bw),
title('line detection image');

%Edge detection
clc;
clear all;
close all;
a = imread('9.3.jpg');
subplot(2,3,1),imshow(a),title('Original');
z=rgb2gray(a);
b = edge(z, 'sobel');
subplot(2,3,2),imshow(b), title('sobel');
c = edge(z, 'roberts');
subplot(2,3,3), imshow(c), title('roberts');
d = edge(z, 'prewitt');
subplot(2,3,4), imshow(d),title('prewitt');
e = edge(z, 'canny');
subplot(2,3,5), imshow(e), title('canny');
f = edge(z, 'log');
subplot(2,3,6),imshow(f),
title('log');

RESULT:
Thus the image segmentation using edge, line and point detection techniques is
performed using MATLAB.
38
BM3652 MEDICAL IMAGE PROCESSING LAB

EX.NO:10 BASIC MORPHOLOGICAL OPERATIONS


DATE

AIM:
To perform basic morphological operations on an image using MATLAB.

THEORY:

Morphological image processing is a collection of non-linear operations related to the


shape or morphology of features in an image. According to Wikipedia, morphological
operations rely only on the relative ordering of pixel values, not on their numerical values, and
therefore are especially suited to the processing of binary images. Morphological operations
can also be applied to greyscale images such that their light transfer functions are unknown and
therefore their absolute pixel values are of no or minor interest.

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 neighbourhood of pixels. Some operations test
whether the element "fits" within the neighbourhood, while others test whether it "hits" or
intersects the neighbourhood

Erosion and dilation

The erosion of a binary image f by a structuring element s (denoted f s) produces a


new binary image g = f s with ones in all locations (x,y) of a structuring element's origin at
which that structuring element s fits the input image f, i.e. g(x,y) = 1 is s fits f and 0 otherwise,
repeating for all pixel coordinates (x,y).

Binary image by Erosion: a 2×2 square structuring


Greyscale image
thresholding element
http://documents.wolfram.com/applications/digitalimage/UsersGuide/Morphology/ImageProce
ssing6.3.html

Erosion with small (e.g. 2×2 - 5×5) square structuring elements shrinks an image by stripping
away a layer of pixels from both the inner and outer boundaries of regions. The holes and gaps
between different regions become larger, and small details are eliminated:

39
EC 8762 DIGITAL IMAGE PROCESSING
LAB

Erosion: a 3×3 square structuring element


(www.cs.princeton.edu/~pshilane/class/mosaic/)
.

Larger structuring elements have a more pronounced effect, the result of erosion with a large
structuring element being similar to the result obtained by iterated erosion using a smaller
structuring element of the same shape. If s1 and s2 are a pair of structuring elements identical in
shape, with s2 twice the size of s1, then

f s2 ≈ (f s1) s1.

Erosion removes small-scale details from a binary image but simultaneously reduces the size of
regions of interest, too. By subtracting the eroded image from the original image, boundaries of
each region can be found: b = f − (f s ) where f is an image of the regions, s is a 3×3
structuring element, and b is an image of the region boundaries.

The dilation of an image f by a structuring element s (denoted f s) produces a new binary


image g = f s with ones in all locations (x,y) of a structuring element's orogin at which that
structuring element s hits the the input image f, i.e. g(x,y) = 1 if s hits f and 0 otherwise,
repeating for all pixel coordinates (x,y). Dilation has the opposite effect to erosion -- it adds a
layer of pixels to both the inner and outer boundaries of regions.

Dilation: a 2×2 square


Binary image
structuring

The holes enclosed by a single region and gaps between different regions become smaller, and
small intrusions into boundaries of a region are filled in:

40
EC 8762 DIGITAL IMAGE PROCESSING
LAB

Dilation: a 3×3 square structuring element


(www.cs.princeton.edu/~pshilane/class/mosaic/)
.

Results of dilation or erosion are influenced both by the size and shape of a structuring element.
Dilation and erosion are dual operations in that they have opposite effects. Let f c denote the
complement of an image f, i.e., the image produced by replacing 1 with 0 and vice versa.
Formally, the duality is written as

41
EC 8762 DIGITAL IMAGE PROCESSING
LAB

f s=fc srot

where srot is the structuring element s rotated by 180 . If a structuring element is symmetrical
with respect to rotation, then srot does not differ from s. If a binary image is considered to be a
collection of connected regions of pixels set to 1 on a background of pixels set to 0, then
erosion is the fitting of a structuring element to these regions and dilation is the fitting of a
structuring element (rotated if necessary) into the background, followed by inversion of the
result.

PROGRAM:

%dilation

clc;
clear all;
close all;
BW=imread("8.jfif");
subplot(2,3,1);
imshow(BW);
title('OriginalImage');
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(2,3,2);
imagesc(B3);
title('K3 Image');

OUTPUT:

Dilation
42
EC 8762 DIGITAL IMAGE PROCESSING
LAB

Erosion

43
EC 8762 DIGITAL IMAGE PROCESSING
LAB

44
EC 8762 DIGITAL IMAGE PROCESSING
LAB

axis('square');
colormap('gray');
subplot(2,3,3);
imagesc(B5);
title('K5 Image');
axis('square');
colormap('gray');
subplot(2,3,4);
imagesc(B7);
title('K7 Image');
axis('square');
colormap('gray');
subplot(2,3,5);
imagesc(B9);
title('K9 Image');
axis('square');
colormap('gray');
% erosion

BW=imread('8.jfif');
subplot(2,3,1);
imshow(BW);
title('original image');
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(2,3,2);
imagesc(B3);
title('K3 Image');
axis('square');
colormap('gray');
subplot(2,3,3);
imagesc(B5);title('K5 Image');
axis('square');
colormap('gray');
subplot(2,3,4);
imagesc(B7); title('K7 Image');
axis('square');
colormap('gray');
subplot(2,3,5);
imagesc(B9); title('K9 Image');
axis('square');
colormap('gray');

RESULT:
Thus the basic morphological operations on an image using MATLAB is performed.

45
EC 8762 DIGITAL IMAGE PROCESSING
LAB

OUTPUT:

46
EC 8762 DIGITAL IMAGE PROCESSING
LAB
EX.NO:11 BASIC THRESHOLDING FUNCTIONS
DATE

AIM:
To perform basic threshold function on an image using MATLAB.

SYNTAX:
THR = thselect(X,TPTR)

THEORY:

Thresholding is the simplest method of image segmentation. From a grayscale image,


thresholding can be used to create binary images. The simplest thresholding methods replace in
an image with a black pixel if the image intensity is less than some fixed constant T or a white
pixel if the image intensity is greater than that constant. In the example image on the right, this
results in the dark tree becoming completely black, and the white snow becoming complete
white.
To make thresholding completely automated, it is necessary for the computer to
automatically select the threshold T. Sezgin and Sankur (2004) categorize thresholding
methods into the following six groups based on the information the algorithm manipulates
(Sezgin et al., 2004):

PROGRAM:

r=imread('circuit board.jpg');
subplot(2,2,1);
imshow(r);
title('Original Image');
subplot(2,2,2);
imshow(r>50);
title('Threshold Image');
level= graythresh(r);
bw = im2bw(r,level);
c= bwareaopen(bw,50);
subplot(2,2,3),
imshow(c)
title('Open area Image');

RESULT:
Thus the basic threshold function on an image is performed using MATLAB.
47
EC 8762 DIGITAL IMAGE PROCESSING
LAB

48
EC 8762 DIGITAL IMAGE PROCESSING
LAB
EX.NO: 12 SEGMENTATION USING WATERSHED TRANSFORM
DATE:

AIM:
To perform segmentation using watershed transform in a MATLAB program environment.

THEORY:
In computer vision, image segmentation is the process of partitioning a digital image into multiple segments. The
goals of segmentation is to simply and for enhance the representation of an image into something that is more meaningful
and easier to analyze. Image segmentation is typically used to locate object 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 show certain visual characteristics.
The result image segmentation is a set of segments that collectively cover the entire image or a set of contours
extracted from the image. Each of the pixels in a region are similar with respect to same characteristic or computed
property, such as color, intensity or texture. Adjuvant regions are significantly different with respect to the same
characteristics 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 algorithm like marching cubes.
Any gray tone image can be considered as a topographic surface. If we flood this surface from its minima and if we
present the merging of the waters coming from different sources, we partition the image into two different sets. The
catchment basins and the watershed transformation to the image gradient, the catchment basins should theoretically
correspond to the homogenous gray level regions of this image.
Because the regions in the image characterized by small variations in gray levels have small gradient values. Thus
in practice, we often see watershed segmentation applied to gradient of an image, rather than to the image itself. The aim of
the watershed transform is to search for regions of high intensity gradients (watershed) that divide neighbor local minima
(basins)

PROGRAM:

afm = imread('erperiment 12.jpg');


subplot(4,4,1),
imshow(afm),
title('surface image');
se= strel('disk',15);
Itop=imtophat(afm,se);
Ibot=imbothat(afm,se);
subplot(4,4,3),
imshow(Itop,[]),title('top-hat image');
subplot(4,4,5),
imshow(Ibot,[]),title('bottom-hat image');
Ienhance=imsubtract(imadd(Itop,afm),Ibot);
subplot(4,4,7),imshow(Ienhance),title('Original+top-hat-bottom-hat');
Iec=imcomplement(Ienhance);
subplot(4,4,9),imshow(Iec),
title('Complement of enhanced image');
Iemin = imextendedmin(Iec,22);
Iimpose=imimposemin(Iec,Iemin);
subplot(4,4,11),
imshow(Iemin),title('extended minima image');
wat=watershed(Iimpose);
rgb=label2rgb(wat);
subplot(4,4,13),
imshow(rgb);title('watershed segmented image');

49
EC 8762 DIGITAL IMAGE PROCESSING
RESULT:
LAB
Thus the segmentation is performed using Watershed transform in a MATLAB program environment

OUTPUT:

50
EC 8762 DIGITAL IMAGE PROCESSING
LAB

EX.NO:13 ANALYSIS OF IMAGES WITH DIFFERENT COLOR MODELS


DATE:

AIM:
To analyze an image with different color models using MATLAB.

COLOR MODELS:
1. NTSC
2. YCbCr
3. HSV
4. CMY
5. CMYK
6. HIS

NTSC
Color model mostly used in analog television system. Garyscale information is
separated from colors details.
It has three components
Luminescence (Y)- grayscale information
Hue(I)- color information
Saturation (Q)- color information
A linear transformation function is used convert RGB image to NTSC image.
YCbCr
Extensively used in digital video luminescence separated by component Y. Color
information represented by Cb and Cr.
Cb – difference between the blue component and a reference
value Cr- difference between the red component and a reference
value.

MATLAB Code
Ycbcr- image =rgb2ycbcr(rgb.image);
Rgb-image= ycbcr2rgb(ycbcr.image);

HSV color image:


HSV (hue saturation value) is one of the several color system used by people to select
color eg.(Points or inks)
HSV color close to RGB color.

51
EC 8762 DIGITAL IMAGE PROCESSING
LAB

OUTPUT:

52
EC 8762 DIGITAL IMAGE PROCESSING
LAB
PROGRAM:

close all;
a=imread('experiment 13.jfif');
subplot(3,3,1);
imshow(a);
title('Original Image');
t=rgb2ntsc(a);
subplot(3,3,2);
imshow(t);
title('NTSC Image');
p=ntsc2rgb(t);
subplot(3,3,3);
imshow(p);
title('RGB Image');
c=rgb2ycbcr(a);
subplot(3,3,4);
imshow(c);
title('YCBR Image');
d=ycbcr2rgb(c);
subplot(3,3,5);
imshow(d);
title('RGB Image');
e=rgb2hsv(a);
subplot(3,3,6);
imshow(e);
title('HSV Image');
y=hsv2rgb(e);
subplot(3,3,7);
imshow(y);
title('RGB Image');
f=imcomplement(a);
subplot(3,3,8);
imshow(f);
title('Complement of Original Image');
g=imcomplement(f);
subplot(3,3,9);
imshow(g);
title('Complement Image');

RESULT:
Thus the image is analyzed using different color models.
53
EC 8762 DIGITAL IMAGE PROCESSING
LAB

54
EC 8762 DIGITAL IMAGE PROCESSING
LAB
EX.NO:14 STUDY OF DICOM STANDARDS
DATE:

AIM:

To study the DICOM Standards and understand the needs.

THEORY:
Digital Imaging and Communications in Medicine (DICOM) is the standard for the communication
and management of medical imaging information and related data.[1] DICOM is most commonly used for
storing and transmitting medical images enabling the integration of medical imaging devices such as
scanners, servers, workstations, printers, network hardware, and picture archiving and communication
systems (PACS) from multiple manufacturers. It has been widely adopted by hospitals and is making inroads
into smaller applications like dentists' and doctors' offices.
DICOM files can be exchanged between two entities that are capable of receiving image and patient data in
DICOM format. The different devices come with DICOM Conformance Statements which state which
DICOM classes they support. The standard includes a file format definition and a network communications
protocol that uses TCP/IP to communicate between systems.
DICOM groups information into data sets. For example, a file of a chest x-ray image may contain the patient
ID within the file, so that the image can never be separated from this information by mistake. This is similar
to the way that image formats such as JPEG can also have embedded tags to identify and otherwise describe
the image.
A DICOM data object consists of a number of attributes, including items such as name, ID, etc., and also one
special attribute containing the image pixel data (i.e. logically, the main object has no "header" as such, being
merely a list of attributes, including the pixel data). A single DICOM object can have only one attribute
containing pixel data. For many modalities, this corresponds to a single image. However, the attribute may
contain multiple "frames", allowing storage of cine loops or other multi-frame data. Another example is NM
data, where an NM image, by definition, is a multi-dimensional multi-frame image. In these cases, three- or
four-dimensional data can be encapsulated in a single DICOM object. Pixel data can be compressed using a
variety of standards, including JPEG, lossless JPEG, JPEG 2000, and run-length encoding (RLE). LZW (zip)
compression can be used for the whole data set (not just the pixel data), but this has rarely been implemented.
DICOM provides detailed engineering information that can be used in interface specifications to
enable network connectivity among a variety of vendors' products. The Standard describes how to format and
exchange medical images and associated information, both within the hospital and also outside the hospital
(e.g., teleradiology, telemedicine). DICOM interfaces are available for connection of any combination of the
following categories of digital imaging devices: (a) image acquisition equipment (e.g., computed
tomography, magnetic resonance imaging, computed radiography, ultrasonography, and nuclear medicine
scanners); (b) image archives; (c) image processing devices and image display workstations; (d) hard-copy
output devices (e.g., photographic transparency film and paper printers).
DICOM is a message standard (i.e., a specification for interchange of information between computer
systems). DICOM is a comprehensive specification of information content, structure, encoding, and
communications protocols for electronic interchange of diagnostic and therapeutic images and image-related
information. Some other healthcare data interchange standards specify only a subset of the properties that
impact interoperability. The Health Level Seven (HL7) Standard2 specifies a message model, but provides
only an abbreviated specification for network communications. The CEN/TC 251/PT3-033 (European

55
EC 8762 DIGITAL IMAGE PROCESSING
Standardization
LAB Committee: Technical Committee for Healthcare, Project Team 22) Request and Report
Messages for Diagnostic Service Departments”3 document specifies a semantic data model and model-based

56
EC 8762 DIGITAL IMAGE PROCESSING
LAB

compositional rules for messages, but only partial guidelines for electronic document interchange. Thus, the
HL7 and CEN/TC 251 specifications leave major communications issues unresolved. Implementors depend
on bilateral negotiation between information system vendors to determine parameters for the unspecified
details. DICOM is a complete specification “from top to bottom” of the elements required to achieve a
practical level of automatic interoperation.

DICOM uses three different data element encoding schemes. With explicit value representation (VR) data
elements, for VRs that are not OB, OW, OF, SQ, UT, or UN[clarification needed], the format for each data
element is: GROUP (2 bytes) ELEMENT (2 bytes) VR (2 bytes) LengthInByte (2 bytes) Data (variable
length). For the other explicit data elements or implicit data elements, see section 7.1 of Part 5 of the DICOM
Standard.
The same basic format is used for all applications, including network and file usage, but when written to a
file, usually a true "header" (containing copies of a few key attributes and details of the application that wrote
it) is added.
DVTk is an Open Source project for testing, validating and diagnosing communication protocols and
scenarios in medical environments. It supports DICOM, HL7 and IHE integration profiles.
Health Level 7 is a non-profit organization involved in the development of international healthcare
informatics interoperability standards. HL7 and DICOM manage a joint Working Group to harmonize areas
where the two standards overlap and address imaging integration in the electronic medical record.
Integrating the Healthcare Enterprise (IHE) is an industry sponsored non-profit organization that profiles the
use of standards to address specific healthcare use cases. DICOM is incorporated in a variety of imaging
related IHE profiles.
Systematized Nomenclature of Medicine (SNOMED) is a systematic, computer-processable collection of
medical terms, in human and veterinary medicine, to provide codes, terms, synonyms and definitions which
cover anatomy, diseases, findings, procedures, microorganisms, substances, etc. DICOM data makes use of
SNOMED to encode relevant concepts.
XnView supports .dic / .dicom for MIME type application/dicom
The best known standards and protocols used by DICOM are:
 DICOM Makes use of the OSI network model. It uses the 2 network protocols on which the Internet
is based and which allow data transfer, TCP / IP, and the HTTP hypertext transfer protocol.
Additionally DICOM has its own MIME content type.
 DICOM uses other protocols such as DHCP, SAML ...
 DICOM makes use of a coding system called SNOMED CT that is based on medical and clinical
terms.
 DICOM uses an external alphabet known as LOINC.
 In the case of breast images, use is made of other types of structured files known as BI-RADS.
Standards that use DICOM
The DICOM standard is used in a wide variety of resources (IHE, HL7 ... a) that are related to images.
The ISO12052: 2017 and CEN 12052 standards refer to the DICOM standard

RESULT:
57
EC 8762 DIGITAL IMAGE PROCESSING
LAB
Thus the DICOM standards and its uses in processing the images were studied.

58
EC 8762 DIGITAL IMAGE PROCESSING
LAB

EX.NO:15 IMAGE COMPRESSION TECHNIQUES


DATE:

AIM:

To apply, study and demonstrate for two dimension DCT in Image Compression Techniques

PROGRAM for DCT:

RGB = imread('circuit board.jpg');


I = im2gray(RGB);
J = dct2(I);
imshow(log(abs(J)),[])
colormap parula
colorbar
J(abs(J) < 10) = 0;
K = idct2(J);
K = rescale(K);
montage({I,K})
title('Original Grayscale Image (Left) and Processed Image (Right)');

59
EC 8762 DIGITAL IMAGE PROCESSING
RESULT:
LAB
Thus the 2D DCT is applied, studied and demonstrated.

Output:

60
EC 8762 DIGITAL IMAGE PROCESSING
LAB

EX.NO: 16 MINI PROJECT - Brighten low-light image


DATE:

AIM:
To apply digital image processing techniques in MATLAB in the conversion of low light image to
Brighten.

PROGRAM:

A = imread('mini.jpg');
subplot(2,2,1);
title("brighten image")
B = imlocalbrighten(A);
montage({A,B})
subplot(2,2,2)
title("image conversion ")
B2 = imlocalbrighten(A,0.8);
montage({B,B2})
subplot(2,2,3)
Bblend = imlocalbrighten(A,'AlphaBlend',true);
montage({B,Bblend})
[~,D] = imlocalbrighten(A);
montage({A,D})

61
EC 8762 DIGITAL IMAGE PROCESSING
LAB

Result:

Thus the brighten image is obtained by using MATLAB techniques.

Output:
Original image conversion image

Brighten image

62
EC 8762 DIGITAL IMAGE PROCESSING
LAB

63

You might also like