DCT code for image hash
Afficher commentaires plus anciens
I am working on a project to assign fingerprint to images using pHash. I happened to get the following code from StackOverflow:
% read image
I = imread('cameraman.tif');
% cosine transform and reduction
d = dct2(I);
d = d(1:8,1:8);
% compute average
a = mean(mean(d));
% set bits, here unclear whether > or >= shall be used
b = d > a;
% maybe convert to string:
string = num2str(b(:)');
When I run the code, I get the following errors, all of which are associated with built-in functions:
Matrix dimensions must agree.
Error in dct (line 76)
b = W .* fft(y);
Error in dct2 (line 50)
b = dct(dct(arg1).').';
Error in flipimage (line 4)
d = dct2(I);
Please help me to resolve these errors
Réponses (1)
Abhishek Ballaney
le 5 Fév 2018
1 vote
https://www.mathworks.com/help/images/ref/dct2.html
Catégories
En savoir plus sur Image Transforms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!