ConstantImage[val,size]
gives an image of the specified size with constant pixel values of val.
ConstantImage[val,size,"type"]
gives an image converted to the specified type.
ConstantImage
ConstantImage[val,size]
gives an image of the specified size with constant pixel values of val.
ConstantImage[val,size,"type"]
gives an image converted to the specified type.
Details and Options
- ConstantImage by default chooses a color space compatible with the given value specification val.
- Constant value val can be any of the following:
-
v gray level from 0 to 1 {c1,c2,…} different channel values ci color any color directive - Size specification size can be one of the following:
-
side 2D image of size {side,side} {width,height} 2D image size specification {width,depth,height} 3D image size specification - ConstantImage[val] is equivalent to ConstantImage[val,{150,150}]. »
- The default "type" is taken to be "Real32".
- ConstantImage supports all Image and Image3D options.
Examples
open all close allBasic Examples (3)
Scope (4)
ConstantImage[LABColor[0.5, 0.8, 0.8], {50, 50}]ImageColorSpace[%]Create a constant image with an arbitrary number of channels:
ConstantImage[{0.1, 0.3, 0.5, 0.7, 0.9}, {50, 50}]ImageChannels[%]If no output image size is specified, a
image is returned:
ConstantImage[Yellow]ImageDimensions[%]By default, an image of a real type is generated:
ConstantImage[Red, {50, 50}]ImageType[%]Specify the output image type:
ConstantImage[Red, {50, 50}, "Byte"]ImageType[%]Options (1)
Applications (1)
Create a constant black image to construct a marker image:
i = [image];zero = ConstantImage[0, ImageDimensions[i]]Replace marker points with white and use for processing:
pts = {{100, 25}, {40, 75}, {35, 45}};
marker = ReplacePixelValue[zero, pts -> 1]FillingTransform[i, marker]Properties & Relations (1)
Construct a constant image using ConstantArray:
Image[ConstantArray[{1, 0, 1}, {50, 100}]]ConstantImage[{1, 0, 1}, {100, 50}]Related Guides
Text
Wolfram Research (2014), ConstantImage, Wolfram Language function, https://reference.wolfram.com/language/ref/ConstantImage.html (updated 2019).
CMS
Wolfram Language. 2014. "ConstantImage." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/ConstantImage.html.
APA
Wolfram Language. (2014). ConstantImage. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ConstantImage.html
BibTeX
@misc{reference.wolfram_2026_constantimage, author="Wolfram Research", title="{ConstantImage}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/ConstantImage.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_constantimage, organization={Wolfram Research}, title={ConstantImage}, year={2019}, url={https://reference.wolfram.com/language/ref/ConstantImage.html}, note=[Accessed: 13-June-2026]}