Skip to content

Commit c18de03

Browse files
authored
refactor: rename IJS class to Image (#146)
1 parent 9e0a7e1 commit c18de03

File tree

132 files changed

+675
-648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+675
-648
lines changed

demo/components/CameraTransform.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useEffect, useRef, useState } from 'react';
22

3-
import { IJS, ImageColorModel, readCanvas, writeCanvas } from '../../src';
3+
import { Image, ImageColorModel, readCanvas, writeCanvas } from '../../src';
44
import { convertColor } from '../../src/operations/convertColor';
55
import { useCameraContext } from '../contexts/cameraContext';
66

77
import ErrorAlert from './ErrorAlert';
88
import UnavailableCamera from './UnavailableCamera';
99

10-
type TransformFunction = (image: IJS) => IJS;
10+
type TransformFunction = (image: Image) => Image;
1111

1212
interface CameraTransformProps {
1313
transform: TransformFunction;

demo/components/Home.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { IJS } from '../../src';
1+
import { Image } from '../../src';
22

33
import CameraSelector from './CameraSelector';
44
import CameraTransform from './CameraTransform';
55
import Container from './Container';
66
import { testGetMbr } from './testFunctions/testGetMbr';
77

8-
function testTransform(image: IJS) {
8+
function testTransform(image: Image) {
99
image.flip({ out: image });
1010
return testGetMbr(image);
1111
}

demo/components/testFunctions/testCannyEdge.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { convertBinaryToGrey, IJS, ImageColorModel } from '../../../src';
1+
import { convertBinaryToGrey, Image, ImageColorModel } from '../../../src';
22

33
/**
44
* Detect the edges in the image using Canny edge detection
55
*
66
* @param image - Input image.
77
* @returns The treated image.
88
*/
9-
export function testCannyEdge(image: IJS): IJS {
9+
export function testCannyEdge(image: Image): Image {
1010
let result = image.convertColor(ImageColorModel.GREY);
1111
result = result.gaussianBlur({ size: 7, sigma: 4 });
1212
const edges = result.cannyEdgeDetector({
@@ -23,7 +23,7 @@ export function testCannyEdge(image: IJS): IJS {
2323
* @param image - Input image.
2424
* @returns The treated image.
2525
*/
26-
export function testCannyEdgeOverlay(image: IJS): IJS {
26+
export function testCannyEdgeOverlay(image: Image): Image {
2727
let result = image.convertColor(ImageColorModel.GREY);
2828
const edges = result.cannyEdgeDetector({
2929
lowThreshold: 0.08,

demo/components/testFunctions/testColorRois.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IJS, ImageColorModel } from '../../../src';
1+
import { Image, ImageColorModel } from '../../../src';
22
import { fromMask, RoisColorMode, colorRois } from '../../../src/roi';
33
import { RoiKind } from '../../../src/roi/getRois';
44

@@ -8,7 +8,7 @@ import { RoiKind } from '../../../src/roi/getRois';
88
* @param image - Input image.
99
* @returns The treated image.
1010
*/
11-
export function testColorRois(image: IJS): IJS {
11+
export function testColorRois(image: Image): Image {
1212
const grey = image.convertColor(ImageColorModel.GREY);
1313
const mask = grey.threshold();
1414

@@ -20,7 +20,7 @@ export function testColorRois(image: IJS): IJS {
2020
});
2121

2222
// create a black image
23-
const black = new IJS(image.width, image.height, {
23+
const black = new Image(image.width, image.height, {
2424
colorModel: ImageColorModel.RGBA,
2525
});
2626
// overlay ROIs on the black image

demo/components/testFunctions/testCopyTo.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { IJS, ImageColorModel } from '../../../src';
1+
import { Image, ImageColorModel } from '../../../src';
22

33
/**
44
* Copy a black and a red square to the source image.
55
*
66
* @param image - Input image.
77
* @returns The treated image.
88
*/
9-
export function testCopyTo(image: IJS): IJS {
9+
export function testCopyTo(image: Image): Image {
1010
let result = image.copyTo(image, {
1111
origin: {
1212
row: image.height / 2,
1313
column: image.width / 2,
1414
},
1515
});
16-
let blackSquare = new IJS(50, 50, { colorModel: ImageColorModel.RGBA });
17-
let redSquare = new IJS(150, 150, { colorModel: ImageColorModel.RGBA });
16+
let blackSquare = new Image(50, 50, { colorModel: ImageColorModel.RGBA });
17+
let redSquare = new Image(150, 150, { colorModel: ImageColorModel.RGBA });
1818
redSquare.fillChannel(0, 255);
1919
redSquare.fillAlpha(100);
2020
result = blackSquare.copyTo(result, {

demo/components/testFunctions/testCorrectColor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IJS } from '../../../src';
1+
import { Image } from '../../../src';
22
import { polishAltered } from '../../../src/correctColor/__tests__/testUtils/imageColors';
33
import { referenceColorCard } from '../../../src/correctColor/__tests__/testUtils/referenceColorCard';
44
import { correctColor } from '../../../src/correctColor/correctColor';
@@ -13,7 +13,7 @@ import {
1313
* @param image - Input image.
1414
* @returns The treated image.
1515
*/
16-
export function testCorrectColor(image: IJS): IJS {
16+
export function testCorrectColor(image: Image): Image {
1717
const measuredColors = getMeasuredColors(polishAltered);
1818
const referenceColors = getReferenceColors(referenceColorCard);
1919
console.log('correct color');

demo/components/testFunctions/testCrop.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DerivativeFilters, IJS, ImageColorModel } from '../../../src';
1+
import { DerivativeFilters, Image, ImageColorModel } from '../../../src';
22
// options
33
const cropImageRatio = 2; // defines the size of the cropped image
44
const interval = 2; // defines the speed
@@ -10,7 +10,7 @@ let row = 0;
1010
let columnInterval: number;
1111
let rowInterval: number;
1212

13-
export function testCropBounce(image: IJS): IJS {
13+
export function testCropBounce(image: Image): Image {
1414
const width = Math.floor(image.width / cropImageRatio);
1515
const height = Math.floor(image.height / cropImageRatio);
1616

Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { DerivativeFilters, IJS, ImageColorModel } from '../../../src';
1+
import { DerivativeFilters, Image, ImageColorModel } from '../../../src';
22

33
/**
44
* Apply a derivative filter to the source image.
55
*
66
* @param image - Input image.
77
* @returns The treated image.
88
*/
9-
export function testDerivativeFilter(image: IJS): IJS {
9+
export function testDerivativeFilter(image: Image): Image {
1010
image = image.convertColor(ImageColorModel.GREY);
1111
return image.derivativeFilter({ filter: DerivativeFilters.PREWITT });
1212
}

demo/components/testFunctions/testExtract.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fromMask, IJS, ImageColorModel } from '../../../src';
1+
import { fromMask, Image, ImageColorModel } from '../../../src';
22
import { RoiKind } from '../../../src/roi/getRois';
33

44
/**
@@ -7,8 +7,8 @@ import { RoiKind } from '../../../src/roi/getRois';
77
* @param image - Input image.
88
* @returns The treated image.
99
*/
10-
export function testExtract(image: IJS): IJS {
11-
const background = new IJS(image.width, image.height, {
10+
export function testExtract(image: Image): Image {
11+
const background = new Image(image.width, image.height, {
1212
colorModel: ImageColorModel.RGBA,
1313
});
1414

@@ -27,7 +27,7 @@ export function testExtract(image: IJS): IJS {
2727
* @param image - The image from which to extract the ROI.
2828
* @returns - The extracted ROI.
2929
*/
30-
export function testExtractRoi(image: IJS): IJS {
30+
export function testExtractRoi(image: Image): Image {
3131
const grey = image.convertColor(ImageColorModel.GREY);
3232
const mask = grey.threshold();
3333

demo/components/testFunctions/testGetBorderPoints.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { fromMask, IJS, ImageColorModel, Mask } from '../../../src';
1+
import { fromMask, Image, ImageColorModel, Mask } from '../../../src';
22
import { RoiKind } from '../../../src/roi/getRois';
33
/**
44
* Paint the border of the larger black ROI on the image.
55
* @param image The image to process
66
* @returns The processed image.
77
*/
8-
export function testGetBorderPoints(image: IJS): IJS {
8+
export function testGetBorderPoints(image: Image): Image {
99
const grey = image.convertColor(ImageColorModel.GREY);
1010
const mask = grey.threshold();
1111

demo/components/testFunctions/testGetConvexHull.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fromMask, IJS, ImageColorModel } from '../../../src';
1+
import { fromMask, Image, ImageColorModel } from '../../../src';
22
import { RoiKind } from '../../../src/roi/getRois';
33

44
/**
@@ -7,7 +7,7 @@ import { RoiKind } from '../../../src/roi/getRois';
77
* @param image - Input image.
88
* @returns The image with the convex Hull.
99
*/
10-
export function testGetConvexHull(image: IJS): IJS {
10+
export function testGetConvexHull(image: Image): Image {
1111
const grey = image.convertColor(ImageColorModel.GREY);
1212
const mask = grey.threshold({ threshold: 35 });
1313
const roiMapManager = fromMask(mask);

demo/components/testFunctions/testGetMask.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { fromMask, IJS, ImageColorModel } from '../../../src';
1+
import { fromMask, Image, ImageColorModel } from '../../../src';
22
import { RoiKind } from '../../../src/roi/getRois';
33
/**
44
* Paint the border of the larger black ROI on the image.
55
* @param image The image to process
66
* @returns The processed image.
77
*/
8-
export function testGetContourMask(image: IJS): IJS {
8+
export function testGetContourMask(image: Image): Image {
99
const grey = image.convertColor(ImageColorModel.GREY);
1010
const mask = grey.threshold();
1111

demo/components/testFunctions/testGetMbr.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fromMask, IJS, ImageColorModel } from '../../../src';
1+
import { fromMask, Image, ImageColorModel } from '../../../src';
22
import { RoiKind } from '../../../src/roi/getRois';
33

44
/**
@@ -7,7 +7,7 @@ import { RoiKind } from '../../../src/roi/getRois';
77
* @param image - Input image.
88
* @returns The image with the MBR.
99
*/
10-
export function testGetMbr(image: IJS): IJS {
10+
export function testGetMbr(image: Image): Image {
1111
const grey = image.convertColor(ImageColorModel.GREY);
1212
const mask = grey.threshold({ threshold: 35 });
1313
const roiMapManager = fromMask(mask);

demo/components/testFunctions/testLevel.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { IJS } from '../../../src';
1+
import { Image } from '../../../src';
22

33
/**
44
* Enhance contrast of the source image using level.
55
*
66
* @param image - Input image.
77
* @returns The treated image.
88
*/
9-
export function testLevel(image: IJS): IJS {
9+
export function testLevel(image: Image): Image {
1010
return image.level({
1111
inputMin: 50,
1212
inputMax: 200,

demo/components/testFunctions/testPaintMask.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { fromMask, IJS, ImageColorModel } from '../../../src';
1+
import { fromMask, Image, ImageColorModel } from '../../../src';
22
import { RoiKind } from '../../../src/roi/getRois';
33
/**
44
* Make the image translucent, excepted where the largest black ROI is.
55
* @param image Image to process.
66
* @returns Processed image.
77
*/
8-
export function testPaintMask(image: IJS): IJS {
8+
export function testPaintMask(image: Image): Image {
99
const grey = image.convertColor(ImageColorModel.GREY);
1010
const mask = grey.threshold({ threshold: 100 });
1111

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { IJS, ImageCoordinates } from '../../../src';
1+
import { Image, ImageCoordinates } from '../../../src';
22

33
/**
44
* Apply a derivative filter to the source image.
55
*
66
* @param image - Input image.
77
* @returns The treated image.
88
*/
9-
export function testRotate(image: IJS): IJS {
9+
export function testRotate(image: Image): Image {
1010
return image.rotate(-15, { center: ImageCoordinates.BOTTOM_RIGHT });
1111
}

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>IJS demo app</title>
6+
<title>image-js demo app</title>
77
</head>
88
<body>
99
<div id="root"></div>

0 commit comments

Comments
 (0)