so I want to change an image from lets say width=500 to width=100, using linear interpolation. How can I do that?
Asked
Active
Viewed 75 times
-3
-
Your question needs improvments: more infomation about the problem, what you tried in order to solve it etc. See here: https://stackoverflow.com/help/how-to-ask. – wohlstad May 09 '22 at 03:43
1 Answers
-1
I'll try to help even though the question requires improvements:
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
- 3,689
- 2
- 9
- 24