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
Copy file name to clipboardExpand all lines: docs/Features/Geometry/Transform.md
+13-9Lines changed: 13 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ _Applies linear transformations to an image, such as scaling, rotation, skewing,
11
11
[🖼️ Image options and parameters of `transform` method](https://image-js.github.io/image-js-typescript/classes/Image.html#transform'github.io link')
12
12
13
13
`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:
15
15
16
16
$$
17
17
\begin{bmatrix}
@@ -21,17 +21,21 @@ g & h & i
21
21
\end{bmatrix}
22
22
$$
23
23
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]`;
25
25
26
26
- the first `a` and `e` are responsible for image scaling
27
27
-`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.
Copy file name to clipboardExpand all lines: docs/Tutorials/Applying transform function on images.md
+14-10Lines changed: 14 additions & 10 deletions
Original file line number
Diff line number
Diff 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.
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.
4
6
5
7
## Types of transformation
6
8
7
-
In this tutorial, we distinguish between two primary types of transformations:
9
+
Here, we distinguish between two primary types of transformations:

222
226
223
227
:::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.
225
229
`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.
226
230
Current tutorial just demonstrates the basic principle behind transformation of such kind.
227
231
:::
@@ -232,12 +236,12 @@ Projective transformations use the full 3×3 matrix, including the bottom row pa
232
236
233
237
### Understanding Perspective Parameters
234
238
235
-
-`g`, `h`: control horizontal and vertical perspective distortion.
239
+
-`g`, `h`: control horizontal and vertical perspective distortions. They allow
236
240
-`i`: Normalization factor (typically 1). It simulates what happens in real vision:
237
241
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
241
245
242
246
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.
243
247
The distortion allows modifying the angle under which you look at the image.
0 commit comments