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() 215 78 148 39 200 147 181 53 119 5 246 91 135 19 101 181 118 15 152 36 204 233 31 17 54 >>> bigger = img.replicate(2) >>> bigger.print() 215 215 78 78 148 148 39 39 200 200 215 215 78 78 148 148 39 39 200 200 147 147 181 181 53 53 119 119 5 5 147 147 181 181 53 53 119 119 5 5 246 246 91 91 135 135 19 19 101 101 246 246 91 91 135 135 19 19 101 101 181 181 118 118 15 15 152 152 36 36 181 181 118 118 15 15 152 152 36 36 204 204 233 233 31 31 17 17 54 54 204 204 233 233 31 31 17 17 54 54
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: