PENGOLAHAN CITRA DIGITAL II
Rosmawi
program histogram citra keabuan
=============================
img=imread('c:\image\boneka.tif');
[jum_baris,jum_kolom]=size(img);
histogram=zeros(256,1);
for baris=1 : jum_baris
for kolom=1 : jum_kolom
histogram(img(baris,kolom) + 1) = ...
histogram(img(baris,kolom) + 1) + 1;
end
end
horijontal=(0:255) ;
bar(horijontal,histogram);
subplot(1,2,1);imshow(img)
subplot(1,2,2);bar(horijontal,histogram)
program pemotongan aras keabuan (menghilangkan derau)
================================================
function [img] = potong(citra,f1,f2)
img=imread(citra);
[jum_baris,jum_kolom]=size(img);
for baris=1 : jum_baris
for kolom=1 : jum_kolom
if img(baris, kolom ) <=f1
img(baris,kolom)=0;
end
if img(baris,kolom) >=f2
img(baris,kolom)=255;
end
end
end
end %akhir fungsi
h=potong('c:\image\daun.tif',30,140);
imshow(h)
p=imread('c:\image\daun.tif');
subplot(1,2,1);imshow(p)
subplot(1,2,2);imshow(h)
cara kedua program pemotongan aras keabuan (masih menyimpan debug)
=======================================================
img=imread('c:\image\daun.tif');
[jum_baris,jum_kolom]=size(img);
for baris=1 : jum_baris
for kolom= 1 : jum_kolom
citra=img;
if citra(baris,kolom) <=30
citra(baris,kolom)=0;
end
if citra(baris,kolom) >=150
citra(baris,kolom)=255;
end
end
end
Komentar
Posting Komentar