Skip to content

Commit ca032fd

Browse files
committed
docs: minor doc fixes
1 parent e23f98b commit ca032fd

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

docs/Features/Geometry/Transform.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ _Applies linear transformations to an image, such as scaling, rotation, skewing,
1111
[🖼️ Image options and parameters of `transform` method](https://image-js.github.io/image-js-typescript/classes/Image.html#transform 'github.io link')
1212

1313
`transform` method uses transformation matrix to rotate, translate, and/or scale the image.
14-
User needs to pass on the matrix that will be applied to the image. Matrix must have 2 rows and 3 columns:
14+
User needs to pass on the matrix that will be applied to the image. Matrix must have either 2 rows and 3 columns or 3 rows and 3 columns:
1515

1616
$$
1717
\begin{bmatrix}
@@ -21,17 +21,21 @@ g & h & i
2121
\end{bmatrix}
2222
$$
2323

24-
Where
24+
If 2x3 matrix is passed, the algorithm will consider it as [affine transformation](https://en.wikipedia.org/wiki/Affine_transformation) so last row will be set as `[0,0,1]`;
2525

2626
- the first `a` and `e` are responsible for image scaling
2727
- `b` and `d` are responsible for [shear](https://en.wikipedia.org/wiki/Shear_mapping 'wikipedia link on image shearing'). Combination of these 4 variables allows [rotating](https://en.wikipedia.org/wiki/Rotations_and_reflections_in_two_dimensions 'wikipedia link on rotation'). `c` and `f` are responsible for image [translation](<https://en.wikipedia.org/wiki/Translation_(geometry)#:~:text=In%20Euclidean%20geometry%2C%20a%20translation,origin%20of%20the%20coordinate%20system> 'wikipedia link on translation').
28-
- `g` and `h` are used for an operation called projection.
29-
:::note
30-
`transform()` function can accept 2x3 as well as 3x3 matrix. If matrix's size is 2x3 that it becomes an affine transformation. This means that transformation happens on the same
31-
:::
32-
:::caution
33-
Matrix cannot be singular. Otherwise it cannot be inverted. Click [here](https://en.wikipedia.org/wiki/Invertible_matrix 'wikipedia link on invertible matrices') to learn more.
34-
:::
28+
- `g` and `h` are used for an operation called projection. It allows changing image perspective.
29+
- `i` is a normalization factor. It acts like a "scaling factor" for the entire coordinate system. Think of it as a zoom lens setting.
30+
31+
For more information take a look at the tutorial about [image transformations](../../Tutorials/Applying%20transform%20function%20on%20images.md)
32+
33+
:::note
34+
`transform()` function can accept 2x3 as well as 3x3 matrix. If matrix's size is 2x3 that it becomes an affine transformation. This means that transformation happens on the same
35+
:::
36+
:::caution
37+
Matrix cannot be singular. Otherwise it cannot be inverted. Click [here](https://en.wikipedia.org/wiki/Invertible_matrix 'wikipedia link on invertible matrices') to learn more.
38+
:::
3539

3640
<TransformDemo />
3741

docs/Tutorials/Applying transform function on images.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
Image transformations are fundamental operations in computer graphics and image processing that allow you to manipulate the position, size, shape, and perspective of images. This tutorial covers both affine and projective transformations, providing practical examples and clear explanations of how each parameter affects your image.
1+
In a broader sense of the term, image transformation refers to the process of modifying or converting images from one form to another. This can involve changes to the image's appearance, format, size, or mathematical representation. Therefore converting image's color model from "RGB" format to greyscale can also be considered a transformation.
22

3-
![Affine transformations](./images/transformations/affine-transform.gif);
3+
In ImageJS, however, `transform()` function does transformations that can be accomplished through [matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication).
4+
5+
In this tutorial we will cover and explain basic transformation techniques as well as explain how `transform()` function allows us to modify images.
46

57
## Types of transformation
68

7-
In this tutorial, we distinguish between two primary types of transformations:
9+
Here, we distinguish between two primary types of transformations:
810

911
### Affine Transformations
1012

13+
![Affine transformations](./images/transformations/affine-transform.gif);
14+
1115
- **Preserve**: Collinearity and ratios of distances
1216
- **Properties**: Parallel lines remain parallel, straight lines remain straight
1317
- **Use cases**: Scaling, rotation, translation, shearing
14-
- **Matrix size**: 2×3(the bottom row [0, 0, 1] is implied)
18+
- **Matrix size**: 2×3(the bottom row `[0, 0, 1]` is implied)
1519

1620
### Projective Transformations
1721

@@ -39,7 +43,7 @@ Each parameter controls specific aspects of the transformation:
3943
- `a`, `e`: Scaling (horizontal and vertical)
4044
- `b`, `d`: Shearing and rotation
4145
- `c`, `f`: Translation (horizontal and vertical)
42-
- `g`, `h`: Perspective distortion
46+
- `g`, `h`: Perspective distortion (horizontal and vertical)
4347
- `i`: Normalization factor (usually 1)
4448

4549
For affine transformation 2x3 matrix will be used, because last row is not necessary for this kind of transformation.
@@ -221,7 +225,7 @@ return image.transform(matrix);
221225
![Rotated by center image](./images/transformations/lennaRotatedCenter.png)
222226

223227
:::note
224-
Image-js has functions `rotate()` and `transformRotate()`. `rotate()` function allows rotating an image by multiple of 90 degrees.
228+
Image-js also has `rotate()` and `transformRotate()` functions. `rotate()` function allows rotating an image by multiple of 90 degrees.
225229
`transformRotate()` allows rotating an image by any degree. It also allows choosing the axe of rotation. So, for rotation, you have other functions that allow you to perform it.
226230
Current tutorial just demonstrates the basic principle behind transformation of such kind.
227231
:::
@@ -232,12 +236,12 @@ Projective transformations use the full 3×3 matrix, including the bottom row pa
232236

233237
### Understanding Perspective Parameters
234238

235-
- `g`, `h`: control horizontal and vertical perspective distortion.
239+
- `g`, `h`: control horizontal and vertical perspective distortions. They allow
236240
- `i`: Normalization factor (typically 1). It simulates what happens in real vision:
237241

238-
1. `i` < 1: Objects farther away appear smaller
239-
2. `i` > 1: Objects closer appear larger
240-
3. The division by w' mathematically recreates this effect
242+
1. `i` < 1: Objects appear larger
243+
2. `i` > 1: Objects appear smaller
244+
3. The division by `i` mathematically recreates this effect
241245

242246
The normalization factor is essentially artificial depth - it makes flat 2D coordinates behave as if they exist in 3D space with varying distances from the viewer.
243247
The distortion allows modifying the angle under which you look at the image.

0 commit comments

Comments
 (0)