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()
   227 203 114  16 135
    46  65  14 177  80
   225 156  80  81  63
   142  94  21 125 154
   143 118  37 243  49
>>> bigger = img.replicate(2)
>>> bigger.print()
   227 227 203 203 114 114  16  16 135 135
   227 227 203 203 114 114  16  16 135 135
    46  46  65  65  14  14 177 177  80  80
    46  46  65  65  14  14 177 177  80  80
   225 225 156 156  80  80  81  81  63  63
   225 225 156 156  80  80  81  81  63  63
   142 142  94  94  21  21 125 125 154 154
   142 142  94  94  21  21 125 125 154 154
   143 143 118 118  37  37 243 243  49  49
   143 143 118 118  37  37 243 243  49  49

Note

  • Works only for greyscale images.

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

References:
Seealso:

decimate