I was writing a program to resize an image while preserving the aspect ratio. Basically, I'm trying to get the source image into a 20x20 box with the aspect ratio preserved.
float ra= (float)20/image.width();
Size dsize = new Size((int)(image.height()*ra),20);
// System.out.println(image.height() + " "+image.width());
//System.out.println((int)(image.height()*ra)+" " + 20);
Imgproc.resize(image,output, dsize,ra,ra, Imgproc.INTER_LINEAR);
The input, image is a Mat. image.height()=10, image.width()=28. The new size would be 7,20.
However when i run the code I get a null pointer exception at Imgproc.resize(). I am unable to find the reason.
I get the same error even if I run
Imgproc.resize(image,output,dsize);