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() 75 166 47 214 2 118 199 158 96 83 27 111 12 3 128 3 33 108 2 242 125 253 156 206 135 >>> bigger = img.replicate(2) >>> bigger.print() 75 75 166 166 47 47 214 214 2 2 75 75 166 166 47 47 214 214 2 2 118 118 199 199 158 158 96 96 83 83 118 118 199 199 158 158 96 96 83 83 27 27 111 111 12 12 3 3 128 128 27 27 111 111 12 12 3 3 128 128 3 3 33 33 108 108 2 2 242 242 3 3 33 33 108 108 2 2 242 242 125 125 253 253 156 156 206 206 135 135 125 125 253 253 156 156 206 206 135 135
- 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: