Java:Data Science Made Easy
上QQ阅读APP看书,第一时间看更新

Resizing an image

Sometimes it is desirable to resize an image. The resize method shown next illustrates how this is done. The image is read in and a new Mat object is created. The resize method is then applied where the width and height are specified in the Size object parameter. The resized image is then saved:

Mat source = Imgcodecs.imread("cat.jpg"); 
Mat resizeimage = new Mat();
Imgproc.resize(source, resizeimage, new Size(250, 250));
Imgcodecs.imwrite("resizedCat.jpg", resizeimage);

The enhanced image follows: