1. An image processing apparatus comprising: a holding unit configured to hold a plurality of spatial transformation matrices for spatial transformation, and a projection matrix for projection operation; a vectorizing unit configured to generate an input image vector by vectorizing at least a partial region of an input image; a determination unit configured to determine a variation attribute by detecting a variation of a target object from a specific state in the input image; and a generation unit configured to select one of the plurality of spatial transformation matrices based on the variation attribute determined by the determination unit, and to generate a transformed image vector by performing the spatial transformation on the input image vector using the selected spatial transformation matrix and to generate a projection vector by performing the projection operation on the transformed vector, using the projection matrix, wherein in the spatial transformation matrices, rows correspond to elements of the transformed image vector, elements of the rows correspond to elements of the input image vector, and in each row, only elements that are referenced when calculating an element value corresponding to the transformed image vector have a value indicating a reference ratio, and the other elements all have a value of 0.