https://www.mathworks.com/help/images/ref/dct2.html
DCT code for image hash
11 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!