clear all, close all, clc;
a = imread('50c.jpg'); //ganti nama file dari gambar uang kamu
figure, imshow(a), title('citra asli-RGB');
%g2=im2double(a);
%figure, imshow(g2), title('double');
g=rgb2gray(a);
figure, imshow(g), title('gray');
%he=histeq(g,256);
%figure, imshow(he),title('citra he');
%perbaikan kualitas citra
he = histeq(g,256);
figure, imshow(he), title ('citra he');
impixelregion
%T = graythresh(g)
%T = 0.35
%tb = im2bw(g,T);
%figure, imshow(tb), title('Biner');
SE1 = [0 1 0; 1 1 1; 0 1 0];
SE2 = [1 0 1; 0 1 0; 1 0 1];
SE3 = [1 1 1; 1 1 1; 1 1 1];
SE = strel('square',3);
td = imdilate(he,SE);
figure, imshow(td), title('dilasi');
te = imerode(td, SE);
figure, imshow(te), title('erosi');
tl= imopen (td, SE1)
figure, imshow(tl), title('opening');
%skelet = bwmorph(te, 'skel', Inf);
%figure, imshow(skelet), title('skelet');
BW = edge(tl,'canny')
figure, imshow(BW), title('canny');
figure,imagesc(BW),colormap('gray'),colorbar('vert');
% Ektraksi Ciri
[B,L] = bwboundaries(BW,'noholes');
stats = regionprops(L,'Area');
s = regionprops(L, 'PixelIdxList', 'PixelList');
hold on;
%imtool(L)
for k = 1
boundary = B{k};
delta_sq = diff(boundary).^2;
sum2 = sum(delta_sq,2);
sum4 = sum2./sum2;
perimeter = sum(sqrt(sum(delta_sq.^2)))
area = stats(k).Area
ik1 = 4*pi*area/perimeter^2
end
for k = 2
boundary = B{k};
delta_sq = diff(boundary).^2;
sum2 = sum(delta_sq,2);
sum4 = sum2./sum2;
perimeter2 = sum(sqrt(sum(delta_sq.^2)))
area2 = stats(k).Area
ik2 = 4*pi*area2/perimeter2^2
end
iktotal = (ik1 + ik2)/2
% impixelregion
%impixelregion(h)
%hfig = impixelregion(area)
if(iktotal <= 2.5810)
msgbox('uang asli');
else
msgbox('uang palsu');
end