A reliable estimate of image pixel (fingerprint ridge) orientations, and block orientations for a given block is determined by finding an optimal block size in an area of an image, e.g., a fingerprint image. An initial block size is chosen. Then a block direction is determined, e.g., by analyzing intensity gradients in two directions, preferably two orthogonal directions, at a plurality (preferably all) of the pixels locations in the block. Block directions of blocks in a given area of the images (fingerprint) are compared. If the compared directions are within a tolerance of one another, the determined direction of the block is considered correct. However, if the compared directions are not within a tolerance of one another, the block size is changed and the process is repeated.