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() 191 104 244 149 5 55 96 211 140 234 59 42 72 99 24 161 146 180 239 15 204 243 31 9 96 >>> bigger = img.replicate(2) >>> bigger.print() 191 191 104 104 244 244 149 149 5 5 191 191 104 104 244 244 149 149 5 5 55 55 96 96 211 211 140 140 234 234 55 55 96 96 211 211 140 140 234 234 59 59 42 42 72 72 99 99 24 24 59 59 42 42 72 72 99 99 24 24 161 161 146 146 180 180 239 239 15 15 161 161 146 146 180 180 239 239 15 15 204 204 243 243 31 31 9 9 96 96 204 204 243 243 31 31 9 9 96 96
- 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: