In digital image processing, the seven moments are rotated, scaled, and translated without changing. Therefore, these seven moments can represent an image. I only tried scaling. These numbers are almost unchanged and may be used for image search.
Code:
Main. m
clear all;close all;clc;img=imread('lena.jpg');fai1=two_dim_moment(img);img1=imresize(img,[100 100]);fai2=two_dim_moment(img1);img2=imresize(img,[300 300]);fai3=two_dim_moment(img2);
Two_dim_moment.m
Function Fai = two_dim_moment (IMG) [m n] = size (IMG); IMG = double (IMG); % moment of each image Mm = zeros (4, 4 ); for y = 1: m for x = 1: N for q = for P = mm (Q, P) = mm (Q, P) + x ^ P-1) * y ^ (q-1) * IMG (Y, x); end mean_x = mm ()/mm (); mean_y = mm) /mm (); % third-order center moment u00 = mm (); u11 = mm ()-mean_y * mm (); u20 = mm) -mean_x * mm (); u02 = mm ()-mean_y * mm (); u30 = mm ()-3 * mean_x * mm) + 2 * mean_x ^ 2 * mm (); U03 = mm ()-3 * mean_y * mm () + 2 * mean_y ^ 2 * mm ); u12 = mm ()-2 * mean_x * mm ()-mean_y * mm () + 2 * mean_x ^ 2 * mm (); u12 = mm) -2 * mean_y * mm ()-mean_x * mm () + 2 * mean_y ^ 2 * mm (); % normalization center moment N20 = u20/u00 ^ 2; n02 = u02/u00 ^ 2; N11 = u11/u00 ^ 2; N30 = u30/u00 ^ 2.5; n03 = U03/u00 ^ 2.5; n12 = u12/u00 ^ 2.5; n21 = u00/u00 ^ 2.5; % 7 moment unchanged Fai (1) = N20 + n02; Fai (2) = (n20-n02) ^ 2 + 4 * N11 ^ 2; fai (3) = (n30-3 * n12) ^ 2 + (3 * n21-n03) ^ 2; Fai (4) = (n30 + n12) ^ 2 + (n21 + n03) ^ 2; Fai (5) = (n30-3 * n12) * (n30 + n12) * (n30 + n12) ^ 2-3*(n21 + n03) ^ 2) + (3 * n21-n03) * (n21 + n03) * (3*(n30 + n12) ^ 2-(n21 + n03) ^ 2); Fai (6) = (n20-n02) * (n30 + n12) ^ 2-(n21 + n03) ^ 2) + 4 * N11 * (n30 + n12) * (n21 + n03 ); fai (7) = (3 * n21-n03) * (n30 + n12) * (n30 + n12) ^ 2-3*(n21 + n03) ^ 2) + (3 * n12-n30) * (n21 + n03) * (3*(n30 + n12) ^ 2-(n21 + n03) ^ 2); End
Result:
Source image:
0.0013419687027165 6.95655523873184e-09 1.24916602133673e-12 1.17939356080133e-11-3.26570081740069e-24-9.12854751096559e-16-4.51507718900331e-23
After amplification:
0.00134188447993572 6.96492642036082e-09 1.25147100094404e-12 1.18051410912046e-11-hour-24-9.14215664936433e-16-4.52621344796181e-23
After shrinking:
0.00134196941138094 6.95708662151456e-09 1.24992393394962e-12 1.17952059702159e-11-3.25857213504391e-24-9.12913251093569e-16-
The magnitude of these numbers is so small that it can be considered almost unchanged.