How to resize images in Java using OpenCV?

I crop the image and want to change it further.

Mat croppedimage = cropImage( image, rect ); Mat resizeimage = croppedimage.resize( any dimension ); //need to change this line 

How can i do this?

+8
java opencv image-resizing
source share
2 answers

I think you want this .

eg.

 Mat croppedimage = cropImage(image,rect); Mat resizeimage = new Mat(); Size sz = new Size(100,100); Imgproc.resize( croppedimage, resizeimage, sz ); 
+32
source share
  • Read the C ++ Resize method manual, it is the same as in java.

  • You can choose the type of interpolation. In some cases, it is important to achieve the best result.

     Mat croppedImage = cropImage(image,rect); Mat resizeImage = new Mat(anyHeight, anyWidth, croppedImage.type()); int interpolation = Imgproc.INTER_CUBIC; Imgproc.resize(croppedImage, resizeImage, resizeImage.size(), 0, 0, interpolation ); 
0
source share

All Articles