Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function determineROI(img: Image, roi: Region): cv.Rect {
return new cv.Rect(
Math.min(Math.max(roi.left, 0), img.width),
Math.min(Math.max(roi.top, 0), img.height),
Math.min(roi.width, img.width - roi.left),
Math.min(roi.height, img.height - roi.top));
}