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.
Examples
>>> from machinevisiontoolbox import Image >>> img = Image.Random(size=5) >>> img.print() 239 104 173 192 73 207 10 151 89 91 201 208 27 223 40 41 175 159 210 151 222 88 180 135 233 >>> bigger = img.replicate(2) >>> bigger.print() 239 239 104 104 173 173 192 192 73 73 239 239 104 104 173 173 192 192 73 73 207 207 10 10 151 151 89 89 91 91 207 207 10 10 151 151 89 89 91 91 201 201 208 208 27 27 223 223 40 40 201 201 208 208 27 27 223 223 40 40 41 41 175 175 159 159 210 210 151 151 41 41 175 175 159 159 210 210 151 151 222 222 88 88 180 180 135 135 233 233 222 222 88 88 180 180 135 135 233 233
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.
See also