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:

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(size=5)
>>> img.print()
     9  79 162 219 250
   177 130  10 243 130
   168 248  52 173 178
   115 240 147 236 187
    23 192  78  23 242
>>> bigger = img.replicate(2)
>>> bigger.print()
     9   9  79  79 162 162 219 219 250 250
     9   9  79  79 162 162 219 219 250 250
   177 177 130 130  10  10 243 243 130 130
   177 177 130 130  10  10 243 243 130 130
   168 168 248 248  52  52 173 173 178 178
   168 168 248 248  52  52 173 173 178 178
   115 115 240 240 147 147 236 236 187 187
   115 115 240 240 147 147 236 236 187 187
    23  23 192 192  78  78  23  23 242 242
    23  23 192 192  78  78  23  23 242 242

Note

  • Works only for greyscale images.

  • The resulting image is “blocky”, apply Gaussian smoothing to reduce this.

References:
Seealso:

decimate