Image.replicate#
- Image.replicate(n: int = 1) Self[source]#
Replicate image pixels
- Parameters:
n (int, optional) – replication factor, defaults to 1
- Returns:
image with replicated pixels
- Return type:
Create an image where each input pixel becomes an \(n \times n\) patch of pixel values. This is a simple way of upscaling an image.
Example:
>>> from machinevisiontoolbox import Image >>> img = Image.Random(size=5) >>> img.print() 15 197 15 48 246 216 39 203 49 206 108 44 183 236 1 213 124 93 124 221 184 59 165 170 190 >>> bigger = img.replicate(2) >>> bigger.print() 15 15 197 197 15 15 48 48 246 246 15 15 197 197 15 15 48 48 246 246 216 216 39 39 203 203 49 49 206 206 216 216 39 39 203 203 49 49 206 206 108 108 44 44 183 183 236 236 1 1 108 108 44 44 183 183 236 236 1 1 213 213 124 124 93 93 124 124 221 221 213 213 124 124 93 93 124 124 221 221 184 184 59 59 165 165 170 170 190 190 184 184 59 59 165 165 170 170 190 190
Note
Works only for greyscale images.
The resulting image is “blocky”, apply Gaussian smoothing to reduce this.
- References:
P. Corke, Robotics, Vision & Control for Python, Springer, 2023, Section 11.7.2.
- Seealso: