-3

I want to change an image from lets say width=500 to width=100, using linear interpolation.
How can I do that?

wohlstad
  • 12,661
  • 10
  • 26
  • 39

1 Answers1

-1

You can use cv::resize to resize the image. The interpolation parameter can be set to cv::INTER_LINEAR for linear interpolation.

Code example:

cv::Mat bigImg(cv::Size(500, 500), CV_8UC1);
// Initialize bigImg in some way ...
cv::Mat smallImg;
cv::resize(bigImg, smallImg, cv::Size(100, 100), 0, 0, cv::INTER_LINEAR);

See the documentation for cv::resize, and interpolation options.

You can also see recommended interpolation method for various cases here: Which kind of interpolation best for resizing image?.

wohlstad
  • 12,661
  • 10
  • 26
  • 39