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
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.
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.
252
287
253
288
### Bicubic Interpolation
254
289
@@ -258,20 +293,7 @@ High-quality image scaling is now available with [bicubic interpolation](https:/
**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.
**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).
**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).
**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.
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
+
388
542
## 🚀 Getting Started
389
543
390
544
To get started with ImageJS, we recommend visiting our ["Get started"](../docs/Getting%20started) guide
0 commit comments