resized the image matrix to improve performance