Skip to content

Commit 90e8dd6

Browse files
committed
(#68) Updated scaleImage function to use lowerBound function
1 parent af02890 commit 90e8dd6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as cv from "opencv4nodejs-prebuilt";
2+
import { lowerBound } from "./bound-value.function";
23

34
export const scaleImage = async (image: cv.Mat, scaleFactor: number): Promise<cv.Mat> => {
4-
const minScaleFactor = (scaleFactor <= 0.0) ? 1.0 : scaleFactor;
5-
const scaledRows = Math.floor(image.rows * minScaleFactor);
6-
const scaledCols = Math.floor(image.cols * minScaleFactor);
5+
const boundScaleFactor = lowerBound(scaleFactor, 0.0, 1.0);
6+
const scaledRows = Math.floor(image.rows * boundScaleFactor);
7+
const scaledCols = Math.floor(image.cols * boundScaleFactor);
78
return image.resizeAsync(scaledRows, scaledCols, 0, 0, cv.INTER_AREA);
89
};

0 commit comments

Comments
 (0)