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()
    87 230  99  98 121
    74 183  10 252  84
   106 204 153 137  99
    55  31 218 197  96
   205  21 231 199  81
>>> bigger = img.replicate(2)
>>> bigger.print()
    87  87 230 230  99  99  98  98 121 121
    87  87 230 230  99  99  98  98 121 121
    74  74 183 183  10  10 252 252  84  84
    74  74 183 183  10  10 252 252  84  84
   106 106 204 204 153 153 137 137  99  99
   106 106 204 204 153 153 137 137  99  99
    55  55  31  31 218 218 197 197  96  96
    55  55  31  31 218 218 197 197  96  96
   205 205  21  21 231 231 199 199  81  81
   205 205  21  21 231 231 199 199  81  81

Note

  • Works only for greyscale images.

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

References:
Seealso:

decimate