RegionImage[reg]
returns a rasterized grayscale 2D or 3D image of reg.
RegionImage[reg,{{xmin,xmax},…}]
restricts to the bounds
.
RegionImage
RegionImage[reg]
returns a rasterized grayscale 2D or 3D image of reg.
RegionImage[reg,{{xmin,xmax},…}]
restricts to the bounds
.
Details and Options
- RegionImage converts regions to 2D and 3D raster images.
- The region reg can be anything that is ConstantRegionQ and a RegionEmbeddingDimension of 2 or 3.
- The following options can be specified:
-
ImageResolution Automatic image resolution in DPI for rasterization ImageSize Automatic final displayed image size in printer's points MetaInformation <||> metainformation to be included in the image Method Automatic method parameters to use RasterSize Automatic raster size in pixels or voxels for rasterization - By default, an automatic thickness is chosen to draw lower-dimensional regions. With Method->{"Thickness"->t}, these regions are rasterized using the absolute thickness t.
Examples
open all close allBasic Examples (2)
Scope (7)
Data (5)
Rasterize a Region:
RegionImage[Region[DiskSegment[{0, 0}, 1, {π / 6, π - π / 6}]]]Rasterize a MeshRegion:
RegionImage[[image]]Rasterize a BoundaryMeshRegion:
ℛ = BoundaryMeshRegion[
{{0, 0}, {3, 0}, {3, 3}, {0, 3}, {1, 1}, {2, 1}, {2, 2}, {1, 2}}, Line[{1, 2, 3, 4, 1}], Line[{5, 6, 7, 8, 5}]
]RegionImage[ℛ]Rasterize a region in 2D with components of 0, 1, and 2 dimensions:
region = Region@RegionUnion[Annulus[], Circle[{0, 0}, 4 / 3], Point[{0, 0}]]RegionImage[region]Rasterize a region in 3D with mixed dimensional components:
region = Region@ParametricRegion[{{x, y, z + y x}, x^2 + y^2 + z^2 <= 1 ∨ z == Sin[x + y] ∨ (x == 0 ∧ y == 0)}, {{x, -1, 1}, {y, -1, 1}, {z, -1, 1}}
]RegionImage[region]Options (6)
Method (4)
"Thickness" (4)
Compare different settings for the thickness of components that are not full dimensional:
mesh = DiscretizeRegion[ImplicitRegion[x == 0∧y == 0 ∨ 1 / 4 ≤ x^2 + y^2 ≤ 1 ∨ x^2 + y^2 == 16 / 9, {x, y}]
]Table[
Labeled[
RegionImage[mesh, RasterSize -> 100, Method -> {"Thickness" -> t}],
Text[t]], {t, {0.5, 1, 2, 4, 8, 16}}
]The thickness is effectively the width of a feature in pixels:
bounds = {{-1.2, 1.2}, {-1.2, 1.2}};
mesh = MeshRegion[
{{0, 0}, {-1, 0}, {0, -1}, {1, 0}, {0, 1}, {1 / 2, 1 / 2}},
{Line[{2, 1, 3, 4, 1, 5}], Point[{6}]},
BaseStyle -> Thick
]Table[
Labeled[
RegionImage[mesh, bounds, RasterSize -> 24, ImageSize -> 100, Method -> {"Thickness" -> t}],
Text[t]
],
{t, 3}
]The default "Thickness"Automatic renders one white pixel per Point:
n = 50;
mesh = MeshRegion[RandomPoint[Disk[], n], Point[Range[n]]];Table[
Labeled[
RegionImage[mesh, {{-1, 1}, {-1, 1}}, Method -> {"Thickness" -> t}, RasterSize -> 100],
Text[t]
],
{t, {Automatic, 0, 1, 2, 4, 8}}
]RegionImage[
Sphere[],
{{-1, 1}, {-1 / 2, 1}, {-1, -1 / 3}},
Method -> {"Thickness" -> 4}
]RasterSize (2)
By default, regions are rasterized to the default graphics raster size:
RegionImage[Annulus[]]ImageDimensions[%]RegionImage[Annulus[], RasterSize -> 100]ImageDimensions[%]Use ImageSize to specify the display size:
RegionImage[Annulus[], ImageSize -> 100]ImageDimensions[%]Applications (6)
Create the image of a Sierpiński mesh:
RegionImage[SierpinskiMesh[6]]i = RegionImage[KnotData["Trefoil", "Region"]]ListAnimate[Image3DSlices[i]]Generate cylindric masks for a volume:
vol = ExampleData[{"TestImage3D", "CTengine"}]
dims = ImageDimensions[vol];mask = Blur[RegionImage[
Region@Cylinder[{{-100, 0, 0}, {100, 0, 0}}, 50], Outer[Times, dims, {-1, 1} / 2],
RasterSize -> dims
]]ImageMultiply[vol, mask]Construct a 3D image from elevation data around Mount Everest:
everest = GeoElevationData[Entity["Mountain", "MountEverest"], Automatic, "Region"]RegionImage[everest]Generate the volume of a polyhedron:
ico = BoundaryMeshRegion@@First[PolyhedronData["Icosahedron"]]RegionImage[ico]"Melting" a snowflake region via curvature flow:
flake = RegionImage[\!\(\*GraphicsBox[«2»]\)]corn = CurvatureFlowFilter[flake, 16]ImageMesh[corn]Possible Issues (2)
Setting the thickness to zero effectively ignores the lower-dimensional components:
RegionImage[Circle[], Method -> {"Thickness" -> 0}]Increase the thickness to get response for lower-dimensional components:
RegionImage[Circle[], Method -> {"Thickness" -> 1}]3D rasterization can show a moiré-like effect due to the partial volume computation and coloring:
vol = RegionImage[Sphere[], {{-1, 1}, {-1 / 2, 1}, {-1, -1 / 3}},
Method -> {"Thickness" -> 2}]Use a color function that changes only opacities based on the voxel intensity, not the color:
vol2 = Image3D[vol, ColorFunction -> (GrayLevel[1, #]&), Background -> Black]Blur[vol2]Antialiasing would even improve a color function that changes both color and opacity by voxel intensities:
Blur[vol]Neat Examples (2)
Estimate the area content of a rasterized disk:
img = RegionImage[
BoundaryDiscretizeRegion[Disk[], PrecisionGoal -> 8], {{-1.2, 1.2}, {-1.2, 1.2}},
RasterSize -> 32
]pixelSize = 2.4 / 32;Compare the area estimate with the disk area π:
area = ImageMeasurements[img, "Total"] pixelSize^2area / πNested conversion between a discretized and mesh representation of a disk:
mesh = BoundaryDiscretizeRegion[Disk[]]Nest[
ImageMesh[
RegionImage[#, {{-1, 1}, {-1, 1}}],
DataRange -> {{-1, 1}, {-1, 1}}
]&,
mesh,
100
]NestList[
ImageMesh[
RegionImage[#, {{-1, 1}, {-1, 1}}],
DataRange -> {{-1, 1}, {-1, 1}}
]&,
mesh,
100
][[1 ;; -1 ;; 25]]Related Guides
History
Text
Wolfram Research (2017), RegionImage, Wolfram Language function, https://reference.wolfram.com/language/ref/RegionImage.html.
CMS
Wolfram Language. 2017. "RegionImage." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RegionImage.html.
APA
Wolfram Language. (2017). RegionImage. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RegionImage.html
BibTeX
@misc{reference.wolfram_2026_regionimage, author="Wolfram Research", title="{RegionImage}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/RegionImage.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_regionimage, organization={Wolfram Research}, title={RegionImage}, year={2017}, url={https://reference.wolfram.com/language/ref/RegionImage.html}, note=[Accessed: 13-June-2026]}