Email: helpdesk@telkomuniversity.ac.id

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/regarding fake currency detection matlab code…it is showing “real” even if i upload fake image,please rectify my code

regarding fake currency detection matlab code…it is showing “real” even if i upload fake image,please rectify my code

PuTI / 2025-01-18
regarding fake currency detection matlab code…it is showing “real” even if i upload fake image,please rectify my code
Matlab News

% Step 1: Load the Image
[FILENAME, PATHNAME] = uigetfile(‘*.jpg’, ‘Select an Image’);
if isequal(FILENAME, 0)
disp(‘User canceled the image selection.’);
return;
end
FilePath = strcat(PATHNAME, FILENAME);
disp(‘Selected Image Location:’);
disp(FilePath);

% Step 2: Read and Resize the Image
DataArray = imread(FilePath); % Read the image
DataArray = imresize(DataArray, [300, 650]); % Resize image to a standard size
figure, imshow(DataArray); % Display image
title(‘Original Image’);

% Step 3: Convert to Grayscale
Igray = rgb2gray(DataArray); % Convert to grayscale
figure, imshow(Igray); % Display grayscale image
title(‘Grayscale Image’);

% Step 4: Noise Removal using Median Filter
Igray = medfilt2(Igray); % Apply median filter to remove noise
figure, imshow(Igray);
title(‘Denoised Grayscale Image’);

% Step 5: Edge Detection (using Sobel operator)
edges = edge(Igray, ‘Sobel’); % Detect edges using Sobel method
figure, imshow(edges);
title(‘Edge Detection’);

% Step 6: Feature Extraction – Texture Features using GLCM
% Calculate the Gray Level Co-occurrence Matrix (GLCM)
glcm = graycomatrix(Igray, ‘Offset’, [0 1; -1 1; -1 0; -1 -1]);
stats = graycoprops(glcm, {‘Contrast’, ‘Correlation’, ‘Energy’, ‘Homogeneity’});

% Extract features from GLCM
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;

% Step 7: Feature Extraction – Shape Features using Regionprops
props = regionprops(edges, ‘Area’, ‘Eccentricity’, ‘Solidity’);
Area = [props.Area]; % Extract Area
Eccentricity = [props.Eccentricity]; % Extract Eccentricity
Solidity = [props.Solidity]; % Extract Solidity

% Step 8: Create Feature Vector
Features = [mean(Contrast), mean(Correlation), mean(Energy), mean(Homogeneity), mean(Area), mean(Eccentricity), mean(Solidity)];
disp(‘Extracted Features:’);
disp(Features);

% Step 9: Prepare Training Data (for SVM)
% Example of real and fake currency training data (manually labeled)
% In real projects, you’d use a dataset with images of real and fake currency
Real_Data = [
% Example feature values for real currency
0.1, 0.9, 0.8, 0.7, 2500, 0.6, 0.95; % Example feature values for real currency
% Add more real currency data points
];

Fake_Data = [
% Example feature values for fake currency
0.5, 0.4, 0.2, 0.3, 2000, 0.8, 0.3; % Example feature values for fake currency
% Add more fake currency data points
];

% Step 10: Labels for Training Data
% 1 for real currency, 0 for fake currency
Real_Labels = ones(size(Real_Data, 1), 1);
Fake_Labels = zeros(size(Fake_Data, 1), 1);

% Combine real and fake data
Train_Data = [Real_Data; Fake_Data];
Train_Labels = [Real_Labels; Fake_Labels];

% Step 11: Train an SVM Classifier
svmModel = fitcsvm(Train_Data, Train_Labels, ‘KernelFunction’, ‘rbf’, ‘Standardize’, true);

% Step 12: Test the classifier with the current image features
[Label, Score] = predict(svmModel, Features); % Classify using the SVM model

% Step 13: Display the result
if Label == 1
msgbox(‘Currency Type: Real’);
else
msgbox(‘Currency Type: Fake’);
end

% Step 14: Display Final Image with Result
figure, imshow(DataArray);
if Label == 1
title(‘Detected: Real Currency’);
else
title(‘Detected: Fake Currency’);
end% Step 1: Load the Image
[FILENAME, PATHNAME] = uigetfile(‘*.jpg’, ‘Select an Image’);
if isequal(FILENAME, 0)
disp(‘User canceled the image selection.’);
return;
end
FilePath = strcat(PATHNAME, FILENAME);
disp(‘Selected Image Location:’);
disp(FilePath);

% Step 2: Read and Resize the Image
DataArray = imread(FilePath); % Read the image
DataArray = imresize(DataArray, [300, 650]); % Resize image to a standard size
figure, imshow(DataArray); % Display image
title(‘Original Image’);

% Step 3: Convert to Grayscale
Igray = rgb2gray(DataArray); % Convert to grayscale
figure, imshow(Igray); % Display grayscale image
title(‘Grayscale Image’);

% Step 4: Noise Removal using Median Filter
Igray = medfilt2(Igray); % Apply median filter to remove noise
figure, imshow(Igray);
title(‘Denoised Grayscale Image’);

% Step 5: Edge Detection (using Sobel operator)
edges = edge(Igray, ‘Sobel’); % Detect edges using Sobel method
figure, imshow(edges);
title(‘Edge Detection’);

% Step 6: Feature Extraction – Texture Features using GLCM
% Calculate the Gray Level Co-occurrence Matrix (GLCM)
glcm = graycomatrix(Igray, ‘Offset’, [0 1; -1 1; -1 0; -1 -1]);
stats = graycoprops(glcm, {‘Contrast’, ‘Correlation’, ‘Energy’, ‘Homogeneity’});

% Extract features from GLCM
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;

% Step 7: Feature Extraction – Shape Features using Regionprops
props = regionprops(edges, ‘Area’, ‘Eccentricity’, ‘Solidity’);
Area = [props.Area]; % Extract Area
Eccentricity = [props.Eccentricity]; % Extract Eccentricity
Solidity = [props.Solidity]; % Extract Solidity

% Step 8: Create Feature Vector
Features = [mean(Contrast), mean(Correlation), mean(Energy), mean(Homogeneity), mean(Area), mean(Eccentricity), mean(Solidity)];
disp(‘Extracted Features:’);
disp(Features);

% Step 9: Prepare Training Data (for SVM)
% Example of real and fake currency training data (manually labeled)
% In real projects, you’d use a dataset with images of real and fake currency
Real_Data = [
% Example feature values for real currency
0.1, 0.9, 0.8, 0.7, 2500, 0.6, 0.95; % Example feature values for real currency
% Add more real currency data points
];

Fake_Data = [
% Example feature values for fake currency
0.5, 0.4, 0.2, 0.3, 2000, 0.8, 0.3; % Example feature values for fake currency
% Add more fake currency data points
];

% Step 10: Labels for Training Data
% 1 for real currency, 0 for fake currency
Real_Labels = ones(size(Real_Data, 1), 1);
Fake_Labels = zeros(size(Fake_Data, 1), 1);

% Combine real and fake data
Train_Data = [Real_Data; Fake_Data];
Train_Labels = [Real_Labels; Fake_Labels];

% Step 11: Train an SVM Classifier
svmModel = fitcsvm(Train_Data, Train_Labels, ‘KernelFunction’, ‘rbf’, ‘Standardize’, true);

% Step 12: Test the classifier with the current image features
[Label, Score] = predict(svmModel, Features); % Classify using the SVM model

% Step 13: Display the result
if Label == 1
msgbox(‘Currency Type: Real’);
else
msgbox(‘Currency Type: Fake’);
end

% Step 14: Display Final Image with Result
figure, imshow(DataArray);
if Label == 1
title(‘Detected: Real Currency’);
else
title(‘Detected: Fake Currency’);
end % Step 1: Load the Image
[FILENAME, PATHNAME] = uigetfile(‘*.jpg’, ‘Select an Image’);
if isequal(FILENAME, 0)
disp(‘User canceled the image selection.’);
return;
end
FilePath = strcat(PATHNAME, FILENAME);
disp(‘Selected Image Location:’);
disp(FilePath);

% Step 2: Read and Resize the Image
DataArray = imread(FilePath); % Read the image
DataArray = imresize(DataArray, [300, 650]); % Resize image to a standard size
figure, imshow(DataArray); % Display image
title(‘Original Image’);

% Step 3: Convert to Grayscale
Igray = rgb2gray(DataArray); % Convert to grayscale
figure, imshow(Igray); % Display grayscale image
title(‘Grayscale Image’);

% Step 4: Noise Removal using Median Filter
Igray = medfilt2(Igray); % Apply median filter to remove noise
figure, imshow(Igray);
title(‘Denoised Grayscale Image’);

% Step 5: Edge Detection (using Sobel operator)
edges = edge(Igray, ‘Sobel’); % Detect edges using Sobel method
figure, imshow(edges);
title(‘Edge Detection’);

% Step 6: Feature Extraction – Texture Features using GLCM
% Calculate the Gray Level Co-occurrence Matrix (GLCM)
glcm = graycomatrix(Igray, ‘Offset’, [0 1; -1 1; -1 0; -1 -1]);
stats = graycoprops(glcm, {‘Contrast’, ‘Correlation’, ‘Energy’, ‘Homogeneity’});

% Extract features from GLCM
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;

% Step 7: Feature Extraction – Shape Features using Regionprops
props = regionprops(edges, ‘Area’, ‘Eccentricity’, ‘Solidity’);
Area = [props.Area]; % Extract Area
Eccentricity = [props.Eccentricity]; % Extract Eccentricity
Solidity = [props.Solidity]; % Extract Solidity

% Step 8: Create Feature Vector
Features = [mean(Contrast), mean(Correlation), mean(Energy), mean(Homogeneity), mean(Area), mean(Eccentricity), mean(Solidity)];
disp(‘Extracted Features:’);
disp(Features);

% Step 9: Prepare Training Data (for SVM)
% Example of real and fake currency training data (manually labeled)
% In real projects, you’d use a dataset with images of real and fake currency
Real_Data = [
% Example feature values for real currency
0.1, 0.9, 0.8, 0.7, 2500, 0.6, 0.95; % Example feature values for real currency
% Add more real currency data points
];

Fake_Data = [
% Example feature values for fake currency
0.5, 0.4, 0.2, 0.3, 2000, 0.8, 0.3; % Example feature values for fake currency
% Add more fake currency data points
];

% Step 10: Labels for Training Data
% 1 for real currency, 0 for fake currency
Real_Labels = ones(size(Real_Data, 1), 1);
Fake_Labels = zeros(size(Fake_Data, 1), 1);

% Combine real and fake data
Train_Data = [Real_Data; Fake_Data];
Train_Labels = [Real_Labels; Fake_Labels];

% Step 11: Train an SVM Classifier
svmModel = fitcsvm(Train_Data, Train_Labels, ‘KernelFunction’, ‘rbf’, ‘Standardize’, true);

% Step 12: Test the classifier with the current image features
[Label, Score] = predict(svmModel, Features); % Classify using the SVM model

% Step 13: Display the result
if Label == 1
msgbox(‘Currency Type: Real’);
else
msgbox(‘Currency Type: Fake’);
end

% Step 14: Display Final Image with Result
figure, imshow(DataArray);
if Label == 1
title(‘Detected: Real Currency’);
else
title(‘Detected: Fake Currency’);
end image processing MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

Warning: Error updating FunctionLine in using fplot
2025-05-12

Warning: Error updating FunctionLine in using fplot

Solid creation Simulink, simscape multibody: stuck in loading
2025-05-12

Solid creation Simulink, simscape multibody: stuck in loading

Issues with EMG Signal Acquisition via Simulink Desktop Real-Time (SDRT) and DAQ Board Usage
2025-05-12

Issues with EMG Signal Acquisition via Simulink Desktop Real-Time (SDRT) and DAQ Board Usage

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: helpdesk@telkomuniversity.ac.id
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss