How to calculate the first-order statistical information for Afghani fake banknote detection?
Show older comments
I want to work on Afghani fake banknote detection project. and i need to crop the banknote image from it's background and then I need to calculate it's first-order statistical information (Variance ,Skewness ,Kurtosis ,and Entropy ) based of it's gray level histogram . so for this i wrote the below code, now can anyone help me , please check my codes and please let me know my code for calculation of the first-order statistical information is correct or not?
Because i am new in matlab so i need help to do this.
%% //Read in images
clear all;
close all;
rgbImage = imread('F:/final_project/dataset/Afghan_fake_banknotes/Real_1000/front/Train/real_39.jpg');
% Get the dimensions of the image. numberOfColorChannels should be = 3.
%rgbImage=imresize(rgbImage,[1024 768]);
[rows, columns, numberOfColorChannels] = size(rgbImage);
% Display the original color image.
subplot(2, 3, 1);
imshow(rgbImage);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0, 1, 1]);
hsvImage = rgb2hsv(rgbImage);
sImage = hsvImage(:, :, 2);
subplot(2, 3, 2);
imshow(sImage, []);
subplot(2, 3, 3);
histogram(sImage);
grid on;
% Threshold.
mask = sImage > 0.1;
% Extract biggest blob.
mask = bwareafilt(mask, 1);
% Fill holes.
mask = imfill(mask, 'holes');
subplot(2, 3, 4);
imshow(mask);
% Get bounding box.
props = regionprops(logical(mask), 'BoundingBox');
% Crop image.
croppedImage = imcrop(rgbImage, props.BoundingBox);
subplot(2, 3, 5);
imshow(croppedImage);
% Grayscal Image
gray1=rgb2gray(croppedImage);
subplot(2, 3, 6);
%imshow(gray1);
% Wiener Filter
filter1=wiener2(gray1);
%filter2=medfilt2(gray1);
imshow(filter1);
%imshow(filter2);
%err1=immse(gray1,filter1);
%err2=immse(gray1,filter2);
histogram1=imhist(filter1);
var1=var(histogram1);
ske1=skewness(histogram1);
kur1=kurtosis(histogram1);
ento1=entropy(histogram1);
Answers (1)
Image Analyst
on 8 Oct 2022
1 vote
I doubt you'd be able to tell from such a poor image. Inconsistent exposures, specular reflections, shadows, physical defects (tears, wrinkles, etc) -- it's a mess. For a reasonably good counterfeit I doubt even a human would be able to tell from the image capture setup you're using.
You'd be better off using a flat bed scanner, though that won't help with the shiny strips and holograms or other angle dependent features they may have in there. Even then it may be almost impossible for your program to find the difference between a legitimate note and a counterfeit one, epsecially if they're both heavily worn, and especially if you're converting the image to gray scale and only analyzing the gray scale version of the image. Only for the most obvious and blatant errors might you be able to find a difference, such as if the building was missing from the counterfeit note.
13 Comments
Image Analyst
on 18 Oct 2022
They look very much similar to me, except that the top note is a bit more worn and the blue vertical strips are different. So in this particular case you could look only at the blue strip. Which one is the legitimate note and which is the counterfeit? Whichever one it is, it's a pretty bad counterfeit. I doubt you'd have it so easy for other counterfeit notes.
One way is to just try to match colors and exposure with imhistmatch, and then align the images with imregister, and then subtract them with imabsdiff and count up the number of difference pixels with an intensity difference more than some specified number.
hamida
on 19 Oct 2022
Image Analyst
on 19 Oct 2022
You would not be able to tell the difference from those two images.
hamida
on 1 Nov 2022
hamida
on 2 Nov 2022
Image Analyst
on 2 Nov 2022
Again, I don't think you'd be able to tell a counterfeit or a badly worn legitimate note from a new legitimate note. You can try calling imregister() and imabsdiff() but for a really good counterfeit, there may be less difference than for a very worn/old true note.
hamida
on 2 Nov 2022
Image Analyst
on 2 Nov 2022
Sure you can try it but you will need to calibrate your images with a ColorChecker chart since otherwise any difference in brightness or color dues to exposure or camera model (that is different from that used to image the legitimate note) could tell you that it's fake when it's not. Even so, unless the fake note is horribly and drastically different you might not notice, particularly because you need to put in some tolerance so that it does not flag legitimate notes as fake just because they are worn a lot.
hamida
on 5 Nov 2022
hamida
on 16 Nov 2022
Image Analyst
on 16 Nov 2022
It's always best to have an intensity standard in there to correct for exposure differences. If you convert to gray scale, it's even more possible that you won't be able to tell legitimate notes from fake ones.
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






