machinevisiontoolbox.Image.replicate
- Image.replicate(n=1)
Replicate image pixels
- Parameters:
n (int, optional) – replication factor, defaults to 1
- Returns:
image with replicated pixels
- Return type:
Image
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(5) >>> img.print() 24 124 165 92 207 58 29 79 171 87 249 44 216 223 127 70 243 34 173 105 158 145 184 100 182 >>> bigger = img.replicate(2) >>> bigger.print() 24 24 124 124 165 165 92 92 207 207 24 24 124 124 165 165 92 92 207 207 58 58 29 29 79 79 171 171 87 87 58 58 29 29 79 79 171 171 87 87 249 249 44 44 216 216 223 223 127 127 249 249 44 44 216 216 223 223 127 127 70 70 243 243 34 34 173 173 105 105 70 70 243 243 34 34 173 173 105 105 158 158 145 145 184 184 100 100 182 182 158 158 145 145 184 184 100 100 182 182
- Note:
Works only for greyscale images.
The resulting image is “blocky”, apply Gaussian smoothing to reduce this.
- References:
Robotics, Vision & Control for Python, Section 11.7.2, P. Corke, Springer 2023.
- Seealso: