Skip to content

Commit fd31809

Browse files
committed
docs: finish documenting api changes
1 parent 26cead8 commit fd31809

File tree

2 files changed

+196
-36
lines changed

2 files changed

+196
-36
lines changed

blog/release.md

Lines changed: 189 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,6 @@ const croppedImage = img.crop({
9191
});
9292
```
9393

94-
Images also include an `origin` that tracks their position relative to their parent's `origin`. When you crop an image, the cropped section remembers where it came from in the original image.
95-
96-
```ts
97-
const croppedImage = img.crop({
98-
origin: { column: 10, row: 10 },
99-
width: 10,
100-
height: 10,
101-
});
102-
103-
console.log(croppedImage.origin); // { column: 10, row: 10 }
104-
```
105-
10694
It is a more explicit and self-documenting code. It also eliminates confusion about array order (column vs row).
10795

10896
### Masks
@@ -188,9 +176,33 @@ Several methods have been renamed for consistency:
188176

189177
`stack.getAverageImage()` ➡️ `stack.meanImage()`
190178

191-
**Other methods**:
179+
**Pixel and value getters/setters**:
180+
181+
`img.getBitXY()` ➡️ `mask.getBit()`
192182

193-
`img.clearBit()` ➡️ `img.setBit()`
183+
`img.getBit()` ➡️ `mask.getBitByIndex()`
184+
185+
`img.getPixelXY()` ➡️ `img.getPixel()`
186+
187+
`img.getPixel()` ➡️ `img.getPixelByIndex()`
188+
189+
`img.getValueXY()` ➡️ `img.getValue()`
190+
191+
`img.getValue()` ➡️ `img.getValueByIndex()`
192+
193+
`img.setBitXY()` ➡️ `mask.setBit()`
194+
195+
`img.setBit()` ➡️ `mask.setBitByIndex()`
196+
197+
`img.setPixelXY()` ➡️ `img.setPixel()`
198+
199+
`img.setPixel()` ➡️ `img.setPixelByIndex()`
200+
201+
`img.setValueXY()` ➡️ `img.setValue()`
202+
203+
`img.setValue()` ➡️ `img.setValueByIndex()`
204+
205+
**Other methods**:
194206

195207
`img.getLocalMaxima()` ➡️ `img.getExtrema()`
196208

@@ -204,6 +216,14 @@ Several methods have been renamed for consistency:
204216

205217
`img.mask()` ➡️ `img.threshold()`
206218

219+
`img.cannyEdge()` ➡️ `img.cannyEdgeDetector()`
220+
221+
`img.blurFilter()` ➡️ `img.blur()`
222+
223+
`img.insert()` ➡️ `img.copyTo()`
224+
225+
`img.convolution()` ➡️ `img.directConvolution()`
226+
207227
### Compatibility requirements
208228

209229
- Node.js: 18+ (previously 14+)
@@ -216,17 +236,23 @@ The following deprecated features have been removed:
216236
#### Images
217237

218238
- `countAlphaPixel()` - Use custom pixel counting with `getPixel()`
219-
- `paintLabels()` and `roi.paint()` - Features were removed due to dependency issues. We plan to add it back in the future updates.
239+
- `paintLabels()` and `roi.paint()` - Features have been removed due to dependency issues. We plan to add it back in the future updates.
220240
- `warpingFourPoints()` - Use `getPerspectiveWarp()` + `transform()`.
221241
- 32-bit color depth has been currently removed. We plan to add it back in the future updates as well.
222242
- `CMYK` and `HSL` color models have been removed.
223-
- `insert()` has been removed.
224243
- `abs()` has been removed.
225244
- `paintMasks()` has been removed. Use `paintMask()`+ `for` loop.
226245
- `clearBit()` and `toggleBit()` have been removed, due to changes in `Mask`
227246
data representation (see ["Masks"](#masks)).
247+
- `combineChannels()` has been removed.
248+
- `rgba8()` and `rgba()` have been removed. Use combination of `convertColorModel()` and `convertBitDepth()`.
249+
- `getRelativePosition()` has been removed.
250+
- `histograms()` and `colorHistogram()` have been removed.
251+
- `getPixelGrid()` has been removed.
252+
- `getClosestCommonParent()` has been removed.
253+
- `getBestMatch()`,`getSimilarity()` and `getIntersection()` have been removed.
228254

229-
#### ROIs and its management
255+
#### ROIs and its management
230256

231257
- `colsInfo()` and `rowsInfo()` have been removed.
232258
- `fromPoints()` has been removed.
@@ -237,6 +263,15 @@ The following deprecated features have been removed:
237263
- `mergeRoi()` and `mergeRois()` have been removed.
238264
- `minX`,`minY`,`meanX`,`meanY`,`maxX`,`maxY` have been removed. Use ROI's `position`, combined with its `width` and `height`.
239265

266+
## 🚀 Performance fixes
267+
268+
Performance of multiple functions has been improved:
269+
270+
- `cannyEdgeDetector()`:
271+
- `resize()`
272+
- `transform()`
273+
- `drawCircle()`
274+
240275
## 🆕 New Features
241276

242277
### `transform()`
@@ -248,7 +283,7 @@ const matrix = getPerspectiveWarp(sourcePoints);
248283
const warped = img.transform(matrix);
249284
```
250285

251-
For more details, visit our [tutorial](/docs/Tutorials/Applying%20transform%20function%20on%20images) on how image transformations work.
286+
For more details, visit our [tutorial](/docs/Tutorials/Applying%20transform%20function%20on%20images) on how image transformations work how they can be used.
252287

253288
### Bicubic Interpolation
254289

@@ -258,20 +293,7 @@ High-quality image scaling is now available with [bicubic interpolation](https:/
258293
const resized = img.resize(800, 600, { interpolation: 'bicubic' });
259294
```
260295

261-
**Use case**: In many cases it gives a better quality when scaling images, especially for photographs.
262-
263-
### Canny Edge Detection
264-
265-
[The Canny Edge Detector](https://en.wikipedia.org/wiki/Canny_edge_detector) is an advanced edge detection filter for computer vision applications:
266-
267-
```ts
268-
const edges = img.cannyEdgeDetector({
269-
lowThreshold: 50,
270-
highThreshold: 150,
271-
});
272-
```
273-
274-
**Use case**: Object detection, image segmentation, feature extraction. You can learn more about it [here](../docs/Features/Morphology/Canny%20Edge%20Detector).
296+
**Use cases**: In many cases it gives a better quality when scaling images, especially for photographs.
275297

276298
### Prewitt filter
277299

@@ -281,7 +303,7 @@ const edges = img.cannyEdgeDetector({
281303
const prewitt = img.derivative({ filter: 'prewitt' });
282304
```
283305

284-
**Use case**: Object detection, image segmentation, feature extraction. You can learn more about it [here](../docs/Features/Morphology/Morphological%20Gradient).
306+
**Use cases**: Object detection, image segmentation, feature extraction. You can learn more about it [here](../docs/Features/Morphology/Morphological%20Gradient).
285307

286308
### Migration from deprecated methods
287309

@@ -296,7 +318,7 @@ const matrix = getPerspectiveWarp(corners);
296318
const warped = img.transform(matrix);
297319
```
298320

299-
**Use case**: Rectification of a perspective angle of an image. You can learn more about it [here](../docs/Features/Geometry/Get%20Perspective%20Warp%20Matrix).
321+
**Use cases**: Rectification of a perspective angle of an image. You can learn more about it [here](../docs/Features/Geometry/Get%20Perspective%20Warp%20Matrix).
300322

301323
### `merge()`
302324

@@ -311,7 +333,103 @@ const img3 = new Image(2, 2, { colorModel: 'GREY', bitDepth: 8 }).fill(255);
311333
const img4 = merge([img1, img2, img3]);
312334
```
313335

314-
**Use case**: Combination of multiple channels into one image after they were modified.
336+
**Use cases**: Combination of multiple channels into one image after they were modified.
337+
338+
### `correctColor()`
339+
340+
This function performs color correction using machine learning to match an image's colors to reference standards.
341+
342+
```ts
343+
const measured = [
344+
{ r: 180, g: 120, b: 90 }, // Colors sampled from the image
345+
{ r: 200, g: 200, b: 180 },
346+
];
347+
const reference = [
348+
{ r: 255, g: 128, b: 64 }, // What those colors should actually be
349+
{ r: 255, g: 255, b: 255 },
350+
];
351+
const corrected = image.correctColor(measured, reference);
352+
```
353+
354+
**Use cases**: Camera calibration, white balance correction, matching images from different devices, scientific imaging standardization.
355+
356+
### `increaseContrast()`
357+
358+
This function increases image contrast by stretching the pixel value range to use the full available dynamic range.
359+
360+
```ts
361+
const highContrast = image.increaseContrast();
362+
```
363+
364+
The function automatically handles different color models, processing only relevant channels (excludes alpha in RGBA, processes only luminance in GREYA). Works with 8-bit and 16-bit images.
365+
366+
**Use cases**: Enhancing low-contrast images, improving visibility of subtle details, preparing images for analysis, correcting underexposed photographs.
367+
368+
### `pixelate()`
369+
370+
`pixelate()` creates a [pixelated effect](https://en.wikipedia.org/wiki/Pixelation 'wikipedia link on pixelation') by dividing the image into square cells and filling each cell with a representative value.
371+
372+
```ts
373+
const pixelatedImage = image.pixelate({
374+
cellSize: 8,
375+
});
376+
```
377+
378+
**Use cases**: Creating retro 8-bit effects, reducing image detail for artistic purposes, or preparing images for low-resolution displays.
379+
380+
### `cropRectangle()`
381+
382+
While `crop()` and `cropRectangle()` might appear similar. However, they provide provide different approaches to extracting image regions.
383+
`crop()` - Standard rectangular cropping that maintains the original image orientation:
384+
385+
```ts
386+
const cropped = image.crop({
387+
column: 10,
388+
row: 10,
389+
width: 50,
390+
height: 50,
391+
});
392+
// Returns a piece of image with the same
393+
// orientation as the parent image.
394+
```
395+
396+
`cropRectangle()` - Advanced cropping that extracts rotated rectangular regions defined by four corner points:
397+
398+
```ts
399+
const points = [
400+
{ row: 30, column: 30 },
401+
{ row: 60, column: 60 },
402+
{ row: 90, column: 30 },
403+
{ row: 60, column: 0 },
404+
];
405+
const rotatedCrop = image.cropRectangle(points);
406+
// Returns a cropped oriented rectangle.
407+
```
408+
409+
Use `crop()` for simple rectangular selections aligned with image axes, and `cropRectangle()` when you need to extract tilted or rotated rectangular regions.
410+
411+
### `drawMarkers()`
412+
413+
Similarly to `drawPoints()`, `drawMarkers()` allows user to annotate an image. However,`drawMarkers()` creates visible markers (crosses, circles, squares, triangles)
414+
which gives a more prominent visual annotation. This gives a better alternative for highlighting or marking features.
415+
416+
```ts
417+
const points = [
418+
{ row: 50, column: 100 },
419+
{ row: 150, column: 200 },
420+
];
421+
422+
const annotated = image.drawMarkers(points, {
423+
shape: 'circle', // Shape of a marker
424+
size: 5,
425+
color: [255, 0, 0], // Red markers
426+
filled: true,
427+
});
428+
```
429+
430+
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.
431+
432+
**Use cases**: Marking detected features, annotating regions of interest, visualizing analysis results, creating overlays for presentations.
315433

316434
### `Stack` features
317435

@@ -385,6 +503,42 @@ const pixelValue = stack.getValueByIndex(stackIndex, pixelIndex, channel);
385503

386504
**Use Cases**: Time-lapse analysis, scientific imaging.
387505

506+
### Image comparison features
507+
508+
ImageJS now has several methods to check feature similarities between two images. For instance, let's take `computeSsim()`.
509+
SSIM (Structural Similarity Index) is a value between -1 and 1 that measures how similar two images are in terms of:
510+
511+
- Luminance
512+
513+
- Contrast
514+
515+
- Structure
516+
517+
`computeSsim()` also has an opposite function `computeDssim()`. It checks _dissimilarities_ between two images.
518+
519+
```ts
520+
// 3x3 grayscale image
521+
const image = new Image(3, 3, {
522+
colorModel: 'GREY',
523+
data: new Uint8Array([5, 5, 5, 10, 10, 10, 15, 15, 15]),
524+
});
525+
const other = image;
526+
527+
console.log(computeSsim(image, other).mssim); // equals to 1, since images are the same.
528+
console.log(computeDssim(image, other)); // equals to 0, since function is the opposite of SSIM.
529+
```
530+
531+
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))
532+
533+
```ts
534+
// Rmse check
535+
computeRmse(image, other);
536+
//PSNR check
537+
computePsnr(image, other);
538+
```
539+
540+
**Use cases**: image quality measurement, detection of changes, or to evaluate visual similarity in tasks like compression, restoration, recognition, and tracking.
541+
388542
## 🚀 Getting Started
389543

390544
To get started with ImageJS, we recommend visiting our ["Get started"](../docs/Getting%20started) guide

project-words.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ electrometric
3030
Grayscaling
3131
Avgs
3232
Collinearity
33-
mmul
33+
mmul
34+
Rmse
35+
Psnr
36+
Ssim
37+
Dssim
38+
mssim
39+
GREYA

0 commit comments

Comments
 (0)