Created
September 24, 2019 21:53
-
-
Save fernandoc1/e69e4c09d0bf4b09076af40c06b13450 to your computer and use it in GitHub Desktop.
This extracts a ROI from images that are 16bits per pixel.
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
void extractRoi(cv::Mat& inImage, cv::Mat& outImage, cv::Rect roi) | |
{ | |
/* Create the image */ | |
outImage = cv::Mat(roi.height, roi.width, inImage.type()); | |
/* Populate the image */ | |
for (int i = roi.y; i < (roi.y+roi.height); i++) | |
{ | |
uint16_t* inP = inImage.ptr<uint16_t>(i); | |
uint16_t* outP = outImage.ptr<uint16_t>(i-roi.y); | |
for (int j = roi.x; j < (roi.x+roi.width); j++) | |
{ | |
outP[j-roi.x] = inP[j]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment