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()
    79  46 238  98  14
    12  54 152   9  21
    68 153 121   5 156
   171 172 165  45 120
   121 198  95  27  31
>>> bigger = img.replicate(2)
>>> bigger.print()
    79  79  46  46 238 238  98  98  14  14
    79  79  46  46 238 238  98  98  14  14
    12  12  54  54 152 152   9   9  21  21
    12  12  54  54 152 152   9   9  21  21
    68  68 153 153 121 121   5   5 156 156
    68  68 153 153 121 121   5   5 156 156
   171 171 172 172 165 165  45  45 120 120
   171 171 172 172 165 165  45  45 120 120
   121 121 198 198  95  95  27  27  31  31
   121 121 198 198  95  95  27  27  31  31

Note

  • Works only for greyscale images.

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

References:
Seealso:

decimate