@@ -103,10 +103,10 @@ const transformationMatrix = [
103
103
[0 , 2 , 0 ], // d=0, e=2 (vertical scale), f=0
104
104
];
105
105
106
- const scaledImage = image .transform (transformationMatrix );
106
+ const scaledImage = image .transform (transformationMatrix , { fullImage: true } );
107
107
```
108
108
109
- ![ Scaled image] ( ./images/transformations/lennaScaled .png )
109
+ ![ Scaled image] ( ./images/transformations/barbaraScaleDemo .png )
110
110
111
111
### Non-uniform Scaling
112
112
@@ -116,11 +116,11 @@ const transformationMatrix = [
116
116
[3 , 0 , 0 ], // Horizontal stretch
117
117
[0 , 0.5 , 0 ], // Vertical compression
118
118
];
119
-
120
- const stretchedImage = image .transform (transformationMatrix );
119
+ // Added trueImage to include all pixels into a destination image
120
+ const stretchedImage = image .transform (transformationMatrix ,, { fullImage: true } );
121
121
```
122
122
123
- ![ Stretched image] ( ./images/transformations/lennaStretched .png )
123
+ ![ Stretched image] ( ./images/transformations/barbaraStretchDemo .png )
124
124
125
125
::: note
126
126
ImageJS also has [ ` resize ` ] ( ../features/geometry/resize.mdx ) function that allows to scale an image.
@@ -135,32 +135,32 @@ const shrinkMatrix = [
135
135
[0.5 , 0 , 0 ],
136
136
[0 , 0.5 , 0 ],
137
137
];
138
- const shrunkImage = image .transform (shrinkMatrix );
138
+ const shrunkImage = image .transform (shrinkMatrix , { fullImage: true } );
139
139
```
140
140
141
- ![ Shrunk image] ( ./images/transformations/lennaShrunk .png )
141
+ ![ Shrunk image] ( ./images/transformations/barbaraShrinkDemo .png )
142
142
143
143
``` ts
144
144
// Mirror horizontally (flip left-right)
145
145
const mirrorMatrix = [
146
146
[- 1 , 0 , 0 ],
147
147
[0 , 1 , 0 ],
148
148
];
149
- const mirroredImage = image .transform (mirrorMatrix );
149
+ const mirroredImage = image .transform (mirrorMatrix , { fullImage: true } );
150
150
```
151
151
152
- ![ Mirrored image] ( ./images/transformations/lennaMirrorred .png )
152
+ ![ Mirrored image] ( ./images/transformations/barbaraMirrorDemo .png )
153
153
154
154
``` ts
155
155
// Mirror vertically (flip up-down)
156
156
const flipMatrix = [
157
157
[1 , 0 , 0 ],
158
158
[0 , - 1 , 0 ],
159
159
];
160
- const flippedImage = image .transform (flipMatrix );
160
+ const flippedImage = image .transform (flipMatrix , { fullImage: true } );
161
161
```
162
162
163
- ![ Flipped image] ( ./images/transformations/lennaFlipped .png )
163
+ ![ Flipped image] ( ./images/transformations/barbaraFlipDemo .png )
164
164
::: note
165
165
ImageJS also has [ ` flip ` ] ( ../features/geometry/flip.mdx ) function that allows to flip an image.
166
166
Current tutorial just demonstrates the basic principle behind transformation of such kind.
@@ -180,7 +180,7 @@ const translationMatrix = [
180
180
const translatedImage = image .transform (translationMatrix );
181
181
```
182
182
183
- ![ Translated image] ( ./images/transformations/lennaTranslated .png )
183
+ ![ Translated image] ( ./images/transformations/barbaraTranslateDemo .png )
184
184
185
185
### Rotation
186
186
@@ -204,7 +204,7 @@ const rotationMatrix = [
204
204
const rotatedImage = image .transform (rotationMatrix );
205
205
```
206
206
207
- ![ Rotated image] ( ./images/transformations/lennaRotated .png )
207
+ ![ Rotated image] ( ./images/transformations/barbaraRotateBy45Demo .png )
208
208
209
209
### Shearing
210
210
@@ -222,7 +222,7 @@ const horizontalShearMatrix = [
222
222
const horizontalShearImage = image .transform (horizontalShearMatrix );
223
223
```
224
224
225
- ![ Horizontally sheared image] ( ./images/transformations/lennaHorizontalShear .png )
225
+ ![ Horizontally sheared image] ( ./images/transformations/barbaraHorizontalShearDemo .png )
226
226
227
227
#### Vertical shearing
228
228
@@ -236,7 +236,7 @@ const verticalShearMatrix = [
236
236
const verticalShearImage = image .transform (verticalShearMatrix );
237
237
```
238
238
239
- ![ Vertically sheared image] ( ./images/transformations/lennaVerticalShear .png )
239
+ ![ Vertically sheared image] ( ./images/transformations/barbaraVerticalShearDemo .png )
240
240
241
241
#### Combined shearing
242
242
@@ -250,7 +250,7 @@ const combinedShearMatrix = [
250
250
const combinedShearImage = image .transform (combinedShearMatrix );
251
251
```
252
252
253
- ![ Combined shearing] ( ./images/transformations/lennaCombinedShear .png )
253
+ ![ Combined shearing] ( ./images/transformations/barbaraCombinedShearDemo .png )
254
254
255
255
### Complex Affine Transformations
256
256
@@ -299,7 +299,7 @@ const rotateAroundCenterImage = image.transform(
299
299
);
300
300
```
301
301
302
- ![ Rotated by center image] ( ./images/transformations/lennaRotatedCenter .png )
302
+ ![ Rotated by center image] ( ./images/transformations/barbaraRotateAroundCenterDemo .png )
303
303
304
304
::: note
305
305
Image-js also has [ ` rotate() ` ] ( ../features/geometry/rotate.mdx ) and [ ` transformRotate() ` ] ( ../features/geometry/transform-and-rotate.mdx ) functions. ` rotate() ` function allows rotating an image by multiple of 90 degrees.
0 commit comments