Você está na página 1de 4

EXPERIMENT-08

AIM-To generates MATLAB code for histogram of an images using MATLAB command and also plot
his image equivalent image.

Theory

Histogram- A histogram is a plot that lets you discover, and show, the underlying frequency
distribution (shape) of a set of continues data. This allows the inspection of the data for its
underlying distribution (e.g., normal distribution), outliers, skewness, etc.

A histogram is a graph. A graph that shows frequency of anything. Usually histograms have bars that
represent frequency of occurring of data in the whole data set.

MATLAB CODE-

clc;
close all;
clear all;
i=imread('pout.tif');
a=histeq(i);
figure(2), imhist(a);
subplot(2,2,1), imshow(i),title('original image')
subplot(2,2,2), imhist(i),title('hestogram image')
subplot(2,2,3), histeq(i),title('equivalent image')
subplot(2,2,4), imhist(a),title('histogram of equlizer image')

RESULT-

original image hestogram image

1500

1000

500

0
0 100 200

equivalent image histogram of equlizer image

1500

1000

500

0
0 100 200
EXPERIMENT-09

AIM-

To generates MATLAB code for histogram of an image.

MATLAB CODE-

clear all;
clc;
close all;
a=imread('pout.tif');
b=zeros(1,255);
[n,m]=size(a);
for x=1:n
for y=1:m
q=a(x,y);
b(q)=b(q)+1;
end
end
subplot(1,2,1);
imshow(uint8(a));
title('Original Image');

subplot(1,2,2);
bar(b);
title('Histogarm of image');

RESULT-

Histogarm of image
4000

Original Image 3500

3000

2500

2000

1500

1000

500

0
0 100 200 300
EXPERIMENT-10

AIM-To generates MATLAB code for 2d-DFT computing and visualization.

Theory

Discrete Fourier transforms:

Working with the Fourier transform on a computer usually involves a form of the transform known as the
discrete Fourier transform (DFT). A discrete transform is a transform whose input and output values are
discrete samples, making it convenient for computer manipulation. There are two principal reasons for using
this form of the transform:

The input and output of the DFT are both discrete, which makes it convenient for computer
manipulations.
There is a fast algorithm for computing the DFT known as the fast Fourier transform (FFT).
The DFT is usually defined for a discrete function f(m,n) that is nonzero only over the finite
region 0mM1 and 0nN1. The two-dimensional M-by-N DFT and inverse M-by-N DFT
relationships are given by

The values F(p,q) are the DFT coefficients of f(m,n). The zero-frequency coefficient, F(0,0), is often
called the "DC component." DC is an electrical engineering term that stands for direct current. (Note
that matrix indices in MATLAB always start at 1 rather than 0; therefore, the matrix elements f(1,1)
and F(1,1) correspond to the mathematical quantities f(0,0) and F(0,0), respectively.)

MATLAB CODE-

%computing and visualing 2d -dft


clc;
clear all;
close all;
f=imread('blobs.png');
[a,b]=size(f);
f=double(f);
ff=fft2(f); % a finer sampling of the Fourier transform
s=abs(ff);
figure(1); subplot(2,1,1); imshow(f); title('original image')
subplot(2,1,2); plot(s); title('plot of abs dft')
s2=log(1+abs(ff)); % dft
fc=fftshift(s); % Shifted transform
s3=log(1+abs(fc)); %after shift dft
figure(2);subplot(1,2,1); imshow((s2),[ ]); title('dft before shift')
subplot(1,2,2); imshow((s3),[ ]); title('dft after shift')
colormap(jet);
figure(3);subplot(2,1,1), plot(fc),title('shifted transform'),colorbar;
subplot(2,1,2), plot(s3),title('log magnitude form'),colorbar;
RESULT-

original image

plot of abs dft


15000

10000

5000

0
0 50 100 150 200 250 300

shifted transform
15000
60

10000
40

5000 20

0
0 50 100 150 200 250 300

log magnitude form


10
60

40
5

20

0
0 50 100 150 200 250 300

Você também pode gostar