The goal is that providing matrix processes which is neccesary for linear algebra or others
- constructor(matrix: number[][], dataType: dataTypes = "Float64")
- public transpose(): Matrix
- public getX(): number
- public getY(): number
- public set(x: number, y: number, number: number): void
- public convertNumberToDataType(number: number, dataType: dataTypes): number
- public getTypedArray():MatrixType
- public get type(): string
- public clone(): number[][]
- public convertDataType(dataType: dataTypes): number[][] | undefined to Matrix class
- public write(options?) options
dataType can be "Float64" | "Float32" | "UInt8" | "UInt16" | "UInt32" | "Int8" | "Int16" | "Int32"
{
rows?: {
start?: number,
end?: number
},
cols?: {
start?: number,
end?: number
}
}
- public static constArithmeticProcess(matrix: Matrix, num: number, process: "mul" | "div" | "sub" | "sum", fixed?: number): Matrix
- public static multiply(matrixFirst: Matrix, matrixSecond: Matrix, options?: ArithmeticProps): Matrix options
- public static sum(matrixFirst: Matrix, matrixSecond: Matrix, options?: ArithmeticProps): Matrix options
{
fixed?: number
}
{
fixed?: number
}
- public static sub(matrixFirst: Matrix, matrixSecond: Matrix, options?: ArithmeticProps): Matrix options
- public static generateMatrix(options: GenerateMatrixProps): Matrix options
- public static ifso(matrix: Matrix, queryFunc: (value: number) => boolean, doFunc: (value: number) => number, doFalseFunc?: (value: number) => number): Matrix
- public static eye(y:number,x:number):Matrix
- public static fill(x:number,y:number,number:number):Matrix
{
fixed?: number
}
{
x: number,
y: number,
fixed?: number,
dataType?: dataTypes,
scala: {
max: number,
min: number
}
}
npm i matrixjs-core
const {Matrix} =require("matrixjs-core")
let matrix=new Matrix([[1,1,1],[1,2,3]])
Matrix.constArithmeticProcess(matrix,3,"mul",2)
import { Matrix } from './index'
import * as jimp from 'jimp'
const rgbToGray=async ()=>{
const myarray:number[][] = [];
await new Promise<any>(resolve=>{
jimp.read("test.jpg").then((image:any) => {
let k=0;
let row:number[]=[]
image.scan(0, 0, image.bitmap.width, image.bitmap.height, function (x:number, y:number, idx:number) {
row.push(Math.round(image.bitmap.data[idx + 0]*0.3+image.bitmap.data[idx + 1]*0.59+image.bitmap.data[idx + 2]*0.11));
k++;
if(k===1280){
myarray.push(row);
k=0;
row=[]
}
})
resolve("ok");
})
})
return myarray;
}
const createImage=(path:string,x:number,y:number,array:number[][])=>{
const test=new jimp(x,y);
const bitmap=test.bitmap;
const fleatted=array.flat();
let i=0;
test.scan(0, 0, x, y, function (_x:number,_y:number, idx:number) {
bitmap.data[idx + 0] = fleatted[i]
bitmap.data[idx + 1] = fleatted[i]
bitmap.data[idx + 2] = fleatted[i]
bitmap.data[idx + 3] = 255
i++;
})
test.writeAsync(path);
}
const init=async ()=>{
const img=new Matrix(await rgbToGray() as number[][],"UInt8");
const croppedImage=img.filter({
rows:{
start:200,
end:500
},
cols:{
start:0,
end:500
}
})
createImage("aa.jpg",croppedImage.getX(),croppedImage.getY(),croppedImage.clone());
}
init();
-
Deprecated
- getMatrix() from Matrix class
-
News
- added 'type' property to Matrix class
- Matrix constructor changed to constructor(matrix: number[][], dataType: dataTypes = "Float64") from constructor(matrix: number[][])
- added public convertDataType(dataType: dataTypes): number[][] | undefined to Matrix class
- added generateMatrix method with dataType
added Data types like "Float64" | "Float32" | "UInt8" | "UInt16" | "UInt32" | "Int8" | "Int16" | "Int32"
- added public getTypedArray():MatrixType method to Matrix class
MatrixType
Uint16Array |
Uint8Array |
Uint32Array |
Int32Array |
Int8Array |
Int16Array | Float32Array | Float64Array | null
- added public set(x: number, y: number, number: number): void
- added public convertNumberToDataType(number: number, dataType: dataTypes): number
- added public static eye(y:number,x:number):Matrix
- added public static fill(x:number,y:number,number:number):Matrix
- Fixed setting value problem
- Solved Maximum call stack size exceeded problem
- Solved shallow clone problem
- Added ravel function
- Added filter function