Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit 888503a

Browse files
authored
chore: enforce types used by API to be exported
1 parent 58041ea commit 888503a

38 files changed

+287
-272
lines changed

.github/workflows/typedoc.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
name: Deploy TypeDoc on GitHub pages
1+
name: Typedoc
22

33
on:
44
workflow_dispatch:
55
push:
66
branches:
77
- main
8+
pull_request:
89

910
env:
1011
NODE_VERSION: 18.x
@@ -24,7 +25,10 @@ jobs:
2425
uses: zakodium/typedoc-action@v2
2526
with:
2627
entry: ${{ env.ENTRY_FILE }}
28+
name: ImageJS
29+
treatWarningsAsErrors: ${{ github.ref != 'refs/heads/main' }}
2730
- name: Deploy to GitHub pages
31+
if: github.ref == 'refs/heads/main'
2832
uses: JamesIves/github-pages-deploy-action@releases/v4
2933
with:
3034
token: ${{ secrets.BOT_TOKEN }}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
"@microsoft/api-extractor": "^7.38.2",
6868
"@tailwindcss/forms": "^0.5.6",
6969
"@types/jest": "^29.5.7",
70-
"@types/js-priority-queue": "^0.0.8",
7170
"@types/jest-image-snapshot": "^6.2.2",
71+
"@types/js-priority-queue": "^0.0.8",
7272
"@types/node": "^20.8.10",
7373
"@types/picomatch": "^2.3.2",
7474
"@types/react": "^18.2.34",
@@ -88,7 +88,7 @@
8888
"jest-image-snapshot": "^6.2.0",
8989
"jest-matcher-deep-close-to": "^3.0.2",
9090
"postcss": "^8.4.31",
91-
"prettier": "^3.0.3",
91+
"prettier": "^3.1.0",
9292
"react": "^18.2.0",
9393
"react-dom": "^18.2.0",
9494
"react-router-dom": "^6.18.0",

src/Image.ts

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
import { RgbColor } from 'colord';
22

33
import { Mask } from './Mask';
4-
import { subtract, add, SubtractImageOptions } from './compare';
5-
import { median } from './compute/median';
4+
import { add, subtract, SubtractImageOptions } from './compare';
5+
import { median } from './compute';
66
import { variance } from './compute/variance';
77
import { correctColor } from './correctColor';
88
import {
9-
drawLineOnImage,
10-
drawPolygonOnImage,
11-
drawPolylineOnImage,
129
drawCircleOnImage,
13-
DrawPolygonOnImageOptions,
14-
DrawPolylineOnImageOptions,
1510
DrawCircleOnImageOptions,
16-
DrawRectangleOptions,
17-
drawRectangle,
11+
drawLineOnImage,
1812
DrawLineOnImageOptions,
19-
drawPoints,
20-
DrawPointsOptions,
2113
drawMarker,
2214
DrawMarkerOptions,
2315
drawMarkers,
16+
drawPoints,
17+
DrawPointsOptions,
18+
drawPolygonOnImage,
19+
DrawPolygonOnImageOptions,
20+
drawPolylineOnImage,
21+
DrawPolylineOnImageOptions,
22+
drawRectangle,
23+
DrawRectangleOptions,
2424
} from './draw';
2525
import {
26-
BlurOptions,
2726
blur,
27+
BlurOptions,
2828
ConvolutionOptions,
29-
directConvolution,
30-
separableConvolution,
31-
gaussianBlur,
32-
GaussianBlurOptions,
33-
HypotenuseOptions,
34-
rawDirectConvolution,
35-
GradientFilterOptions,
36-
gradientFilter,
3729
derivativeFilter,
3830
DerivativeFilterOptions,
31+
directConvolution,
3932
flip,
4033
FlipOptions,
34+
gaussianBlur,
35+
GaussianBlurOptions,
36+
gradientFilter,
37+
GradientFilterOptions,
4138
hypotenuse,
39+
HypotenuseOptions,
4240
invert,
4341
InvertOptions,
4442
level,
4543
LevelOptions,
4644
increaseContrast,
4745
IncreaseContrastOptions,
48-
pixelate,
49-
PixelateOptions,
5046
medianFilter,
5147
MedianFilterOptions,
48+
pixelate,
49+
PixelateOptions,
50+
rawDirectConvolution,
51+
separableConvolution,
5252
} from './filters';
5353
import {
5454
Point,
@@ -61,7 +61,6 @@ import {
6161
transformRotate,
6262
TransformRotateOptions,
6363
} from './geometry';
64-
import { ImageMetadata } from './load/getMetadata';
6564
import {
6665
bottomHat,
6766
BottomHatOptions,
@@ -81,20 +80,21 @@ import {
8180
TopHatOptions,
8281
} from './morphology';
8382
import {
83+
convertBitDepth,
8484
convertColor,
8585
ConvertColorOptions,
86-
convertBitDepth,
8786
copyTo,
8887
CopyToOptions,
8988
crop,
89+
CropAlphaOptions,
9090
CropOptions,
9191
grey,
9292
paintMaskOnImage,
9393
PaintMaskOnImageOptions,
9494
split,
9595
} from './operations';
96-
import { cropAlpha, CropAlphaOptions } from './operations/cropAlpha';
97-
import { ImageColorModel, colorModels } from './utils/constants/colorModels';
96+
import { cropAlpha } from './operations/cropAlpha';
97+
import { colorModels, ImageColorModel } from './utils/constants/colorModels';
9898
import { getMinMax } from './utils/getMinMax';
9999
import { validateChannel, validateValue } from './utils/validators/validators';
100100

@@ -104,6 +104,7 @@ import {
104104
GreyOptions,
105105
histogram,
106106
HistogramOptions,
107+
ImageMetadata,
107108
mean,
108109
threshold,
109110
ThresholdOptions,

src/Mask.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { subtract, SubtractImageOptions } from './compare';
33
import {
44
drawLineOnMask,
55
DrawLineOnMaskOptions,
6+
drawPoints,
7+
DrawPointsOptions,
68
drawPolygonOnMask,
79
DrawPolygonOnMaskOptions,
810
drawPolylineOnMask,
911
DrawPolylineOnMaskOptions,
1012
drawRectangle,
1113
DrawRectangleOptions,
1214
} from './draw';
13-
import { drawPoints, DrawPointsOptions } from './draw/drawPoints';
1415
import {
1516
and,
1617
AndOptions,
@@ -19,15 +20,11 @@ import {
1920
or,
2021
OrOptions,
2122
} from './filters';
22-
import {
23-
GetBorderPointsOptions,
24-
getBorderPoints,
25-
getConvexHull,
26-
ConvexHull,
27-
Feret,
28-
getFeret,
29-
} from './maskAnalysis';
30-
import { getMbr, Mbr } from './maskAnalysis/getMbr';
23+
import { ConvexHull, Feret, GetBorderPointsOptions, Mbr } from './maskAnalysis';
24+
import { getBorderPoints } from './maskAnalysis/getBorderPoints';
25+
import { getConvexHull } from './maskAnalysis/getConvexHull';
26+
import { getFeret } from './maskAnalysis/getFeret';
27+
import { getMbr } from './maskAnalysis/getMbr';
3128
import {
3229
bottomHat,
3330
BottomHatOptions,
@@ -37,6 +34,7 @@ import {
3734
CloseOptions,
3835
dilate,
3936
DilateOptions,
37+
erode,
4038
ErodeOptions,
4139
floodFill,
4240
FloodFillOptions,
@@ -49,7 +47,6 @@ import {
4947
topHat,
5048
TopHatOptions,
5149
} from './morphology';
52-
import { erode } from './morphology/erode';
5350
import {
5451
convertColor,
5552
copyTo,
@@ -58,7 +55,7 @@ import {
5855
PaintMaskOnMaskOptions,
5956
} from './operations';
6057
import { boolToNumber } from './utils/boolToNumber';
61-
import { ImageColorModel, colorModels } from './utils/constants/colorModels';
58+
import { colorModels, ImageColorModel } from './utils/constants/colorModels';
6259
import { Point } from './utils/geometry/points';
6360

6461
export type BitValue = 1 | 0 | boolean;
@@ -323,8 +320,7 @@ export class Mask {
323320
* @param value - Value to set.
324321
*/
325322
public setBitByIndex(index: number, value: BitValue): void {
326-
const result = boolToNumber(value);
327-
this.data[index * this.channels] = result;
323+
this.data[index * this.channels] = boolToNumber(value);
328324
}
329325

330326
/**

src/compare/computeRmse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Image } from '..';
22

33
/**
44
* Compute the Root Mean Square Error (RMSE) between two images. It is just the square root of the MSE.
5-
* {@see @link https://en.wikipedia.org/wiki/Root-mean-square_deviation}
5+
* @see {@link https://en.wikipedia.org/wiki/Root-mean-square_deviation}
66
* @param image - First image.
77
* @param otherImage - Second image.
88
* @returns RMSE of the two images.

src/featureMatching/descriptors/getBriefDescriptors.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { Image } from '../../Image';
22
import { GaussianBlurSigmaOptions } from '../../filters';
3+
import { GetGaussianPointsOptions } from '../../utils/utils.types';
34
import checkProcessable from '../../utils/validators/checkProcessable';
45
import { OrientedFastKeypoint } from '../keypoints/getOrientedFastKeypoints';
56
import { compareIntensity } from '../utils/compareIntensity';
6-
import {
7-
getGaussianPoints,
8-
GetGaussianPointsOptions,
9-
} from '../utils/getGaussianPoints';
7+
import { getGaussianPoints } from '../utils/getGaussianPoints';
108

119
import { getKeypointPatch } from './utils/getKeypointPatch';
1210

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export interface GetColorsOptions {
2+
/**
3+
* Number of shades to generate.
4+
* @default `6`
5+
*/
6+
nbShades?: number;
7+
/**
8+
* Factor between 0 and 1 by which to multiply the maximal value of the color to obtain the minimum value.
9+
* @default `0.2`
10+
*/
11+
minValueFactor?: number;
12+
}
13+
14+
export interface GetHarrisScoreOptions {
15+
/**
16+
* Size of the window to compute the Harris score.
17+
* Should be an odd number so that the window can be centered on the corner.
18+
* @default `7`
19+
*/
20+
windowSize?: number;
21+
/**
22+
* Constant for the score computation. Should be between 0.04 and 0.06 (empirical values). This consant is commonly called k.
23+
* @default `0.04`
24+
*/
25+
harrisConstant?: number;
26+
}

src/featureMatching/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './descriptors/getBriefDescriptors';
2+
export * from './featureMatching.types';
23
export * from './keypoints/getFastKeypoints';
34
export * from './keypoints/getIntensityCentroid';
45
export * from './keypoints/getOrientedFastKeypoints';

src/featureMatching/keypoints/getFastKeypoints.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import {
77
import { getIndex } from '../../utils/getIndex';
88
import { surroundingPixels } from '../../utils/surroundingPixels';
99
import checkProcessable from '../../utils/validators/checkProcessable';
10+
import { GetHarrisScoreOptions } from '../featureMatching.types';
1011

1112
import { getFastScore } from './getFastScore';
12-
import { getHarrisScore, GetHarrisScoreOptions } from './getHarrisScore';
13+
import { getHarrisScore } from './getHarrisScore';
1314
import { isFastKeypoint, IsFastKeypointOptions } from './isFastKeypoint';
1415

1516
export interface GetFastKeypointsOptions extends IsFastKeypointOptions {

src/featureMatching/keypoints/getHarrisScore.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,7 @@ import Matrix, { EigenvalueDecomposition, WrapperMatrix1D } from 'ml-matrix';
33
import { Image } from '../../Image';
44
import { Point } from '../../geometry';
55
import { SOBEL_X, SOBEL_Y } from '../../utils/constants/kernels';
6-
7-
export interface GetHarrisScoreOptions {
8-
/**
9-
* Size of the window to compute the Harris score.
10-
* Should be an odd number so that the window can be centered on the corner.
11-
* @default `7`
12-
*/
13-
windowSize?: number;
14-
/**
15-
* Constant for the score computation. Should be between 0.04 and 0.06 (empirical values). This consant is commonly called k.
16-
* @default `0.04`
17-
*/
18-
harrisConstant?: number;
19-
}
6+
import { GetHarrisScoreOptions } from '../featureMatching.types';
207

218
/**
229
* Get the Harris score of a corner. The idea behind the algorithm is that a

0 commit comments

Comments
 (0)