You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new approach allows for better TypeScript inference, smaller bundle sizes through tree-shaking, and clearer API design where I/O operations are separate from image manipulation.
57
+
Those changes separates I/O operations from image manipulation for a clearer API design.
58
58
59
59
#### Creating
60
60
@@ -63,13 +63,13 @@ When creating a new image, unlike before, image's width and height must be speci
63
63
```ts
64
64
import { Image } from'image-js';
65
65
66
-
// Would work before, will throw an error in a new version.
66
+
// Would work before, will throw an error in the new version.
67
67
const image =newImage();
68
68
// Works fine.
69
69
const image2 =newImage(10, 10);
70
70
```
71
71
72
-
This change makes the Image constructor more explicit by requiring you to specify the dimensions upfront, preventing potential errors from working with uninitialized or undefined-sized images
72
+
This change makes the Image constructor more explicit by requiring you to specify the dimensions upfront, preventing potential errors from working with uninitialized or undefined-sized images.
`Mask` provides better type safety, clearer API, and optimized performance for binary operations.
110
+
`Mask` provides better type safetyand clearer API.
111
111
112
112
The new `Mask` class uses 1 byte per pixel (vs 8 pixels per byte), trading ~8x memory usage for significantly faster bit operations and simpler data manipulation.
113
113
@@ -168,6 +168,8 @@ Several methods have been renamed for consistency:
168
168
169
169
`img.paintCircle()` β‘οΈ `img.drawCircle()`
170
170
171
+
`img.paintPoints()` β‘οΈ `img.drawMarkers()`
172
+
171
173
**Stack methods**
172
174
173
175
`stack.getMinImage()` β‘οΈ `stack.minImage()`
@@ -226,33 +228,37 @@ Several methods have been renamed for consistency:
The following deprecated features have been removed:
237
244
238
245
#### Images
239
246
240
-
-`countAlphaPixel()` - Use custom pixel counting with `getPixel()`
241
-
-`paintLabels()` and `roi.paint()` - Features have been removed due to dependency issues. We plan to add it back in the future updates.
242
-
-`warpingFourPoints()` - Use `getPerspectiveWarp()` + `transform()`.
243
-
- 32-bit color depth has been currently removed. We plan to add it back in the future updates as well.
247
+
-`countAlphaPixel()` - Use custom pixel counting with [`getPixel()`](https://image-js.github.io/image-js/classes/index.Image.html#getpixel'API link on getPixel').
248
+
-`paintLabels()` and `roi.paint()` - Features have been removed due to dependency issues. We plan to add it back in future updates.
249
+
-`warpingFourPoints()` - Use [`getPerspectiveWarpMatrix()`](../docs/Features/Geometry/Get%20Perspective%20Warp%20Matrix'internal link on getPerspectiveWarp') + [`transform()`](release.md#transform) instead.
250
+
- 32-bit color depth support and `abs()` have been removed.
244
251
-`CMYK` and `HSL` color models have been removed.
245
-
-`abs()` has been removed.
246
-
-`paintMasks()` has been removed. Use `paintMask()`+ `for` loop.
252
+
-`paintMasks()` has been removed. Use [`paintMask()`](https://image-js.github.io/image-js/classes/index.Image.html#paintmask'API link on paintMask')+ a `for` loop.
247
253
-`clearBit()` and `toggleBit()` have been removed, due to changes in `Mask`
248
-
data representation (see ["Masks"](#masks)).
254
+
data representation (see ["Masks"](#masks)). Use [`setBit()`](https://image-js.github.io/image-js/classes/index.Mask.html#setbit'API link on setBit') or [`setValue()`](https://image-js.github.io/image-js/classes/index.Image.html#setvalue'API link on setValue') instead.
249
255
-`combineChannels()` has been removed.
250
-
-`rgba8()` and `rgba()` have been removed. Use combination of `convertColorModel()` and `convertBitDepth()`.
251
-
-`getRelativePosition()` has been removed.
256
+
-`rgba8()` and `rgba()` have been removed. Use a combination of [`convertColor()`](https://image-js.github.io/image-js/classes/index.Image.html#convertcolor'API link on convertColor') and [`convertBitDepth()`](https://image-js.github.io/image-js/classes/index.Image.html#convertbitdepth'API link on convertBitDepth') instead.
252
257
-`histograms()` and `colorHistogram()` have been removed.
253
258
-`getPixelGrid()` has been removed.
254
-
-`getClosestCommonParent()`has been removed.
259
+
-`getClosestCommonParent()`and `getRelativePosition()` have been removed.
255
260
-`getSimilarity()` and `getIntersection()` have been removed.
261
+
-`paintPolygons()` and `paintPolylines()`have been removed. Use [`drawPolygon()`](https://image-js.github.io/image-js/classes/index.Image.html#drawpolygon'API link on drawPolygon')/ [`drawPolyline()`](https://image-js.github.io/image-js/classes/index.Image.html#drawpolyline'API link on drawPolyline') + a `for` loop.
256
262
257
263
#### ROIs and its management
258
264
@@ -263,16 +269,7 @@ The following deprecated features have been removed:
263
269
-`findCorrespondingRoi()` has been removed.
264
270
-`resetPainted()` has been removed.
265
271
-`mergeRoi()` and `mergeRois()` have been removed.
266
-
-`minX`,`minY`,`meanX`,`meanY`,`maxX`,`maxY` have been removed. Use ROI's `position`, combined with its `width` and `height`.
267
-
268
-
## π Performance fixes
269
-
270
-
Performance of multiple functions has been improved:
271
-
272
-
-`cannyEdgeDetector()`:
273
-
-`resize()`
274
-
-`transform()`
275
-
-`drawCircle()`
272
+
-`minX`,`minY`,`meanX`,`meanY`,`maxX`,`maxY` have been removed. Use [ROI's `position`, combined with its `width` and `height`](https://image-js.github.io/image-js/classes/index.Roi.html'API link on ROI').
For more details, visit our [tutorial](/docs/Tutorials/Applying%20transform%20function%20on%20images) on how image transformations work how they can be used.
285
+
For more details, visit our [tutorial](/docs/Tutorials/Applying%20transform%20function%20on%20images'internal link on transform function tutorial') on how image transformations work how they can be used.
289
286
290
287
### Bicubic Interpolation
291
288
292
-
High-quality image scaling is now available with [bicubic interpolation](https://en.wikipedia.org/wiki/Bicubic_interpolation):
289
+
High-quality image scaling is now available with [bicubic interpolation](https://en.wikipedia.org/wiki/Bicubic_interpolation'wikipedia link on bicubic interpolation'):
**Use cases**: Object detection, image segmentation, feature extraction. You can learn more about it [here](../docs/Features/Morphology/Morphological%20Gradient).
305
+
**Use cases**: Object detection, image segmentation, feature extraction. You can learn more about it [here](../docs/Features/Morphology/Morphological%20Gradient'internal link on morphological gradient').
309
306
310
307
### Migration from deprecated methods
311
308
312
-
`warpingFourPoints()` has been removed. Now you have [`getPerspectiveWarp()`](../docs/Features/Geometry/Get%20Perspective%20Warp%20Matrix) that returns a matrix that can be applied on the image of interest in a new `transform()`.
309
+
`warpingFourPoints()` has been removed. Now you have [`getPerspectiveWarp()`](../docs/Features/Geometry/Get%20Perspective%20Warp%20Matrix'internal link on perspective warp') that returns a matrix that can be applied on the image of interest in a new `transform()`.
**Use cases**: Rectification of a perspective angle of an image. You can learn more about it [here](../docs/Features/Geometry/Get%20Perspective%20Warp%20Matrix).
320
+
**Use cases**: Rectification of a perspective angle of an image. You can learn more about it [here](../docs/Features/Geometry/Get%20Perspective%20Warp%20Matrix'internal link on perspective warp').
Use `crop()` for simple rectangular selections aligned with image axes, and `cropRectangle()` when you need to extract tilted or rotated rectangular regions.
412
410
413
-
### `drawMarkers()`
411
+
### `drawPoints()`
414
412
415
-
Similarly to `drawPoints()`, `drawMarkers()` allows user to annotate an image. However,`drawMarkers()` creates visible markers (crosses, circles, squares, triangles)
416
-
which gives a more prominent visual annotation. This gives a better alternative for highlighting or marking features.
413
+
This function draws individual 1x1 pixel points at the specified coordinates. Unlike drawMarker() which creates shaped markers (circles, crosses, etc.), drawPoints() renders simple single-pixel points, making it ideal for dense point visualization or precise coordinate marking.
417
414
418
415
```ts
419
416
const points = [
420
417
{ row: 50, column: 100 },
421
418
{ row: 150, column: 200 },
422
419
];
423
420
424
-
const annotated =image.drawMarkers(points, {
425
-
shape: 'circle', // Shape of a marker
426
-
size: 5,
427
-
color: [255, 0, 0], // Red markers
428
-
filled: true,
421
+
const annotated =image.drawPoints(points, {
422
+
color: [255, 0, 0], // Red dots
429
423
});
430
424
```
431
425
432
-
Each marker is drawn centered on the specified point coordinates. The function creates a new image without modifying the original, making it ideal for creating annotated versions while preserving source data.
426
+
Each point is drawn centered on the specified point coordinates. The function creates a new image without modifying the original, making it ideal for creating annotated versions while preserving source data.
The `Mask` has been enhanced with new methods for geometric analysis and border processing.
433
+
434
+
#### `getFeret()`
433
435
434
-
**Use cases**: Marking detected features, annotating regions of interest, visualizing analysis results, creating overlays for presentations.
436
+
Computes the [Feret diameters](https://en.wikipedia.org/wiki/Feret_diameter'wikipedia link on Feret diameters') of the mask region, which are fundamental measurements in particle analysis and shape characterization. The Feret diameter represents the distance between two parallel lines that are tangent to the object's boundary.
437
+
438
+
```ts
439
+
const feretDiameters =mask.getFeret();
440
+
/*An object containing:
441
+
minDiameter: The minimum Feret diameter (narrowest width)
442
+
maxDiameter: The maximum Feret diameter (longest distance between any two boundary points)
443
+
aspectRatio: Ratio of minimum to maximum diameter (minDiameter.length / maxDiameter.length)*/
444
+
```
445
+
446
+
**Use cases**: Particle size analysis, shape characterization, elongation measurement, quality control in manufacturing, biological specimen analysis.
447
+
448
+
#### `getBorderPoints()`
449
+
450
+
Extracts all points that lie on the border/perimeter of the mask regions. This method identifies pixels that are part of the mask but have at least one neighboring pixel that is not part of the mask.
451
+
452
+
```ts
453
+
const borderPoints =mask.getBorderPoints();
454
+
// Returns: Array of {row: number, column: number} objects
Removes mask regions that are connected to the image borders. This operation uses flood fill to eliminate any connected components that have pixels touching the edge of the image, useful for removing incomplete objects that extend beyond the image boundaries.
ImageJS now has several methods to check feature similarities between two images. For instance, let's take `computeSsim()`.
511
-
SSIM ([Structural Similarity Index](https://en.wikipedia.org/wiki/Structural_similarity_index_measure)) is a value between -1 and 1 that measures how similar two images are in terms of:
512
-
513
-
- Luminance
514
-
515
-
- Contrast
516
-
517
-
- Structure
518
-
519
-
`computeSsim()` also has an opposite function `computeDssim()`. It checks _dissimilarities_ between two images.
console.log(computeSsim(image, other).mssim); // equals to 1, since images are the same.
530
-
console.log(computeDssim(image, other)); // equals to 0, since function is the opposite of SSIM.
531
-
```
532
-
533
-
ImageJS also includes such metrics like RMSE([Root Mean Square Error](https://en.wikipedia.org/wiki/Root-mean-square_deviation),measures the average magnitude of pixel differences between two images, giving more weight to larger errors) and PSNR( [Peak Signal-to-Noise Ratio](https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio), derived from MSE. It expresses the ratio between the maximum possible pixel value and the error (MSE))
544
+
## π Bug fixes
534
545
535
-
```ts
536
-
// Rmse check
537
-
computeRmse(image, other);
538
-
//PSNR check
539
-
computePsnr(image, other);
540
-
```
541
-
542
-
**Use cases**: image quality measurement, detection of changes, or to evaluate visual similarity in tasks like compression, restoration, recognition, and tracking.
543
-
544
-
## π Getting Started
546
+
Bugs in multiple functions have been fixed:
545
547
546
-
To get started with ImageJS, we recommend visiting our ["Get started"](../docs/Getting%20started) guide
0 commit comments