Comparing version 1.0.2 to 1.0.4
/** | ||
* 线性滤波 | ||
* 线性滤波器 | ||
* [1, 2, 3, [1, 2, 3, | ||
@@ -18,3 +18,6 @@ * 4, 5, 6, * 4, 5, 6, | ||
* @param col 取源数据的开始col位置 | ||
* @param step 每一像素的步长,默认为灰度图为1,如果是rgba 则为4 | ||
* @param offset 取步长中偏移量的值 | ||
* @param axis 轴方向 默认xy xy|x|y | ||
*/ | ||
export declare const getLinearMatData: (src: number[], srcWidth: number, kernelSize: number, row: number, col: number) => any[]; | ||
export declare const getLinearMatData: (src: number[], srcWidth: number, kernelSize: number, row: number, col: number, step?: number, offset?: number, axis?: "x" | "y" | "xy") => any[] | undefined; |
@@ -9,3 +9,3 @@ "use strict"; | ||
/** | ||
* 线性滤波 | ||
* 线性滤波器 | ||
* [1, 2, 3, [1, 2, 3, | ||
@@ -30,2 +30,5 @@ * 4, 5, 6, * 4, 5, 6, | ||
* @param col 取源数据的开始col位置 | ||
* @param step 每一像素的步长,默认为灰度图为1,如果是rgba 则为4 | ||
* @param offset 取步长中偏移量的值 | ||
* @param axis 轴方向 默认xy xy|x|y | ||
*/ | ||
@@ -37,13 +40,39 @@ | ||
var getLinearMatData = function getLinearMatData(src, srcWidth, kernelSize, row, col) { | ||
var out = new Array(Math.pow(kernelSize, 2)).fill(0); | ||
var step = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1; | ||
var offset = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0; | ||
var axis = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : "xy"; | ||
for (var i = 0; i < kernelSize; i += 1) { | ||
for (var j = 0; j < kernelSize; j += 1) { | ||
out[i * kernelSize + j] = src[srcWidth * (row + i) + j + col]; | ||
if (axis === "xy") { | ||
var out = new Array(Math.pow(kernelSize, 2)).fill(0); | ||
for (var i = 0; i < kernelSize; i += 1) { | ||
for (var j = 0; j < kernelSize; j += 1) { | ||
out[i * kernelSize + j] = src[(srcWidth * (row + i) + j + col) * step + offset]; | ||
} | ||
} | ||
return out; | ||
} | ||
return out; | ||
if (axis === "y") { | ||
var _out = new Array(kernelSize).fill(0); | ||
for (var _i = 0; _i < kernelSize; _i += 1) { | ||
_out[_i] = src[(srcWidth * (row + _i) + col) * step + offset]; | ||
} | ||
return _out; | ||
} | ||
if (axis === "x") { | ||
var _out2 = new Array(kernelSize).fill(0); | ||
for (var _i2 = 0; _i2 < kernelSize; _i2 += 1) { | ||
_out2[_i2] = src[(srcWidth * row + _i2 + col) * step + offset]; | ||
} | ||
return _out2; | ||
} | ||
}; | ||
exports.getLinearMatData = getLinearMatData; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "xy-math", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34524
16
747