Home > front end >  Change image range using linear interpolation
Change image range using linear interpolation

Time:05-09

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

CodePudding user response:

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?.

  • Related