Cara membuat Histogram menggunakan Matlab :
1. Buka aplikasi matlab
2. Pilih New untuk membuka Editornya
3. Tulis coding di Editor untuk membuat Histogram
4. Pilih Save as untuk menyimpan file editor yang sudah di terisi coding tadi
5. Pilih Debug / RUN / F5
Adapun Coding untuk membuat Histogram adalah sebagai berikut :
clear all;
close all;
l=imread('whinie.jpg');
l1=rgb2gray(l);
figure(1)
subplot(1,2,1)
imshow(l1)
title('Original Image');
[counts x]=imhist(l1);
counts1=counts(2:256-1,:);
x1=[2:1:255];
h=hist(counts1,x1);
p=histeq(l1,h);
subplot(1,2,2)
imshow(p);
title('Processed Image');
hold on;
figure(2)
subplot(1,2,1)
imhist(l1)
title('Histogram of Original Image');
subplot(1,2,2)
imhist(p)
title('Histogram of Processed Image');
hold on;
k=mean2(l1);
k2=mean2(p);
dev=std2(l1);
dev1=std2(p);
[co xi]=imhist(l1,8);
[co1 xi1]=imhist(p,8);
m=mean2(xi);
m2=mean2(xi1);
stdev=std2(xi);
stdev1=std2(xi1);
disp('********Comparison of Mean and Standard Deviation for Whole Image and 8x8 Block*********');
disp('Original Image');
disp('Mean of Whole Image=')
disp(k);
disp('Mean for 8x8 Sub-Block of Intensities=');
disp(m);
disp('Standard Deviation of Whole Image=')
disp(dev);
disp('Standard Deviation for 8x8 Sub-Block of Intensities=');
disp(stdev);
disp('Processed Image');
disp('Mean of Whole Image=')
disp(k2);
disp('Mean for 8x8 Sub-block of Intensities=');
disp(m2);
disp('Standard Deviation of Whole Image=')
disp(dev1);
disp('Standard Deviation for 8x8 Sub-block of Intensities=');
disp(stdev1);
Output Program :

output Histogram :

0 komentar:
Posting Komentar