Created
September 3, 2014 06:34
-
-
Save ashwin/565a6f8f09ce69367aab to your computer and use it in GitHub Desktop.
Resize or rescale image in OpenCV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int kNewWidth = 200; | |
const int kNewHeight = 400; | |
const float kRescaleFactor = 0.75; | |
/** | |
* Resize mat | |
*/ | |
Mat mat; // Input | |
Mat new_mat; | |
resize(mat, new_mat, cvSize(kNewWidth, kNewHeight)); | |
/** | |
* Rescale mat | |
*/ | |
Mat mat; // Input | |
Mat new_mat; | |
resize(mat, new_mat, cvSize(0, 0), kScaleFactor, kScaleFactor); | |
/** | |
* Resize IplImage | |
*/ | |
IplImage* img; // Input | |
IplImage* new_img = cvCreateImage(cvSize(kNewWidth, kNewHeight), img->depth, img->nChannels); | |
cvResize(img, new_img); | |
/** | |
* Rescale IplImage | |
*/ | |
IplImage* img; // Input | |
const int new_width = (int) ((float) img->width * kRescaleFactor); | |
const int new_height = (int) ((float) img->height * kRescaleFactor); | |
IplImage* new_img = cvCreateImage(cvSize(new_width, new_height), img->depth, img->nChannels); | |
cvResize(img, new_img); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment