WOLFRAM

gives an image with pseudorandom pixel values in the range 0 to max.

RandomImage[{min,max}]

generates pseudorandom pixel values in the range min to max.

RandomImage[dist]

generates pixel values using a symbolic distribution dist.

RandomImage[,size]

generates a random image of the specified size.

RandomImage[,size,"type"]

gives an image converted to the specified type.

Details and Options

  • RandomImage gives an image where pixel values are drawn from a specified distribution. The pixel values are not correlated spatially.
  • Random images can be used for creating synthetic noise images and image effects.
  • RandomImage by default gives an image of a real type.
  • RandomImage[] is equivalent to RandomImage[1,{150,150}].
  • RandomImage[] is equivalent to RandomImage[,{150,150}].
  • The size specification can be one of the following:
  • side2D image of size {side,side}
    {width,height}2D image size specification
    {width,depth,height}3D image size specification
  • Possible settings for "type" include:
  • "Bit"integer 0 or 1
    "Byte"integer 0 through 255
    "Bit16"integer 0 through 65535
    "Real32"single-precision real (32 bit)
    "Real64"double-precision real (64 bit)
  • RandomImage accepts all Image and Image3D options with the following additions and modifications:
  • ColorSpace Automaticgenerates an image of the specified color space
    InterleavingNonewhether to generate an interleaved image

Examples

open allclose all

Basic Examples  (3)Summary of the most common use cases

Generate a random image:

Out[1]=1

Generate a random RGB image:

Out[1]=1

Generate a random 3D image:

Out[1]=1

Scope  (8)Survey of the scope of standard use cases

Distribution  (5)

By default, pixel values range from 0 to 1:

Out[1]=1

Specify a range of pixel values:

Out[1]=1
Out[2]=2

Generate an image from pseudorandom values in the range 0 to :

Out[1]=1
Out[2]=2

A random image from a normal distribution:

Out[1]=1
Out[2]=2

Generate a 4-channel image using some multivariate distribution:

Out[1]=1
Out[2]=2

Size  (2)

By default, a 2D image is generated:

Out[2]=2

Specify the image dimensions for a square image:

Out[1]=1

Specify the image dimensions:

Out[1]=1

Specify the 3D image dimensions:

Out[1]=1

Type  (1)

By default a real image is created:

Out[1]=1

Create a byte image:

Out[2]=2

Options  (5)Common values & functionality for each option

ColorSpace  (4)

By default, no explicit color space is assumed:

Out[1]=1
Out[2]=2

Generate a "Grayscale" image:

Out[3]=3
Out[4]=4

Generate a random "RGB" image:

Out[1]=1

Generate an "HSB" image using some univariate distribution:

Out[1]=1

Generate a "LAB" image using a multivariate uniform distribution with specific bounds:

Out[1]=1

ImageSize  (1)

By default, the image is created with ImageSize->Automatic:

Out[1]=1

Specify the display size:

Out[2]=2

Applications  (4)Sample problems that can be solved with this function

Additive noise:

Out[1]=1

Multiplicative noise:

Out[1]=1

Image of Laplacian noise:

Out[1]=1

RGB image simulating salt-and-pepper noise using a heavy-tail distribution:

Out[1]=1

Properties & Relations  (7)Properties of the function, and connections to other functions

Generate an image with constant intensity:

Out[1]=1

Use the specialized function ConstantImage instead:

Out[2]=2

Generate the random data using RandomReal:

Out[1]=1

Generate a random binary image using RandomInteger:

Out[1]=1

Generate the random data using RandomVariate:

Out[1]=1

In a uniformly random image, neighboring pixels are not correlated:

Out[1]=1
Out[2]=2
Out[3]=3

After local filtering, pixel values drawn from the original distribution are spatially correlated:

Out[4]=4
Out[5]=5

Create an image with pixels randomly chosen from a list of colors:

Out[1]=1

Create an image from colors randomly chosen from a convex hull defined by a list of colors:

Out[1]=1

Possible Issues  (1)Common pitfalls and unexpected behavior

Out-of-range pixel values are rendered as black or white:

Out[3]=3

Use ImageAdjust to see the full range of values:

Out[4]=4

Neat Examples  (1)Surprising or curious use cases

Show the effect of various types of noise: original image, Poisson noise, uniform noise, Gaussian noise, Laplacian noise, salt-and-pepper noise:

Out[4]=4
Wolfram Research (2010), RandomImage, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomImage.html (updated 2020).
Wolfram Research (2010), RandomImage, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomImage.html (updated 2020).

Text

Wolfram Research (2010), RandomImage, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomImage.html (updated 2020).

Wolfram Research (2010), RandomImage, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomImage.html (updated 2020).

CMS

Wolfram Language. 2010. "RandomImage." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/RandomImage.html.

Wolfram Language. 2010. "RandomImage." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/RandomImage.html.

APA

Wolfram Language. (2010). RandomImage. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomImage.html

Wolfram Language. (2010). RandomImage. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomImage.html

BibTeX

@misc{reference.wolfram_2025_randomimage, author="Wolfram Research", title="{RandomImage}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/RandomImage.html}", note=[Accessed: 24-April-2025 ]}

@misc{reference.wolfram_2025_randomimage, author="Wolfram Research", title="{RandomImage}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/RandomImage.html}", note=[Accessed: 24-April-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_randomimage, organization={Wolfram Research}, title={RandomImage}, year={2020}, url={https://reference.wolfram.com/language/ref/RandomImage.html}, note=[Accessed: 24-April-2025 ]}

@online{reference.wolfram_2025_randomimage, organization={Wolfram Research}, title={RandomImage}, year={2020}, url={https://reference.wolfram.com/language/ref/RandomImage.html}, note=[Accessed: 24-April-2025 ]}