Skip to content

Instantly share code, notes, and snippets.

View wlucas-DFT's full-sized avatar

Will Lucas wlucas-DFT

View GitHub Profile
@wlucas-DFT
wlucas-DFT / centerCropMat
Created March 9, 2015 19:10
Does a simple percentage based center crop.
Mat centerCropMat(const cv::Mat& image, double cropPercentage)
{
cropPercentage = min(cropPercentage, 1.0);
int newRows = (int)floor(image.rows * cropPercentage + 0.5);
int newCols = (int)floor(image.cols * cropPercentage + 0.5);
Point center(image.cols / 2, image.rows / 2);
Rect roi(
center.x - (newCols / 2),