Here, we resize the image into 1 quarter of the original image, with half height and width comparing to original image.
#include <iostream>
#include <opencv2/opencv.hpp>
int main(int argc, const char * argv[])
{
// Read original image into varialbe img
cv::Mat img = cv::imread("/Users/herbert19lee/Desktop/lena1.jpg");
// Declare variable img_resize as container for resized image
// Declare variable img_resize as container for resized image
cv::Mat img_resize;
// resize the original img, as half size of original cols and rows
// cv::Size2i(img.cols/2, img.rows/2) is where you specify the desired dimension for resized image
// cv::Size2i(img.cols/2, img.rows/2) is where you specify the desired dimension for resized image
cv::resize(img, img_resize, cv::Size2i(img.cols/2, img.rows/2));
// Visualize the original and resized image in window: lena and lena_resize respectively.
cv::namedWindow("lena");
cv::namedWindow("lena_resize");
cv::imshow("lean", img);
cv::imshow("lena_resize", img_resize);
cv::waitKey();
return 0;
}
hmm, seems confusing..
ReplyDeleteCv Template