({{, (RefLink[ImagePyramid, paclet:ref/ImagePyramid])[image] 
creates a Gaussian image pyramid formed from image.}, {, (RefLink[ImagePyramid, paclet:ref/ImagePyramid])[image,pyrtype]
returns a Gaussian or Laplacian pyramid depending of the specified pyrtype.}, {, (RefLink[ImagePyramid, paclet:ref/ImagePyramid])[image,pyrtype,n]
returns up to n levels of the pyramid.}, {, (RefLink[ImagePyramid, paclet:ref/ImagePyramid])[image,pyrtype,{size}]
returns pyramid levels down to image dimensions given by size.}, {, (RefLink[ImagePyramid, paclet:ref/ImagePyramid])[image,pyrtype,n,s]
returns a pyramid with successive levels downsampled by factor s.}})

OpenersNotesSection(Spacer1)Details and Options

Image pyramid is a multi-resolution representation of an image to facilitate efficient multiscale processing. Typical applications include noise removal, image blending, texture synthesis and efficient rendering.

An image pyramid consists of several images with consecutively lower resolutions. Typically, specific levels of the pyramid are processed, and the result is reconstructed using the inverse process.

(RefLink[ImagePyramid, paclet:ref/ImagePyramid]) works with arbitrary 2D and 3D images.

Use (RefLink[InverseImagePyramid, paclet:ref/InverseImagePyramid]) to reconstruct the image from an image pyramid.

The pyramid type pyrtype can be any of the following:

Kernel specification ker can be given by an array or any valid setting for (RefLink[Resampling, paclet:ref/Resampling]).

By default, (RefLink[ImagePyramid, paclet:ref/ImagePyramid])[image] creates a Gaussian pyramid with all possible levels using a scaling factor of 2.

Using pyr["Properties"], all available properties are returned.

Using pyr["prop"], properties or content of the constructed image pyramid can be extracted.

Available properties "prop" are:

Level specification levels can take any of the following settings:

(RefLink[ImagePyramid, paclet:ref/ImagePyramid]) preserves the image type when creating a lowpass pyramid and returns a pyramid of a real type when creating a bandpass pyramid.

By default, a "Reversed" padding is used. Use (RefLink[Padding, paclet:ref/Padding]) option to specify other settings.

OpenersPrimaryExamplesSection(Spacer1)Examples  (17)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Compute a lowpass pyramid:

pyr=ImagePyramid[]

View all image levels:

pyr[All]

Compute a bandpass pyramid:

pyr=ImagePyramid[,"Bandpass"]

View all image levels, adjusting the images to see the details:

Map[ImageAdjust,pyr[All]]

OpenersExampleSection1(Spacer1)Scope  (7)

OpenersExampleSubsection0(Spacer1)Data  (3)

Lowpass pyramid of a 2D image:

pd = ImagePyramid[]

View all image levels:

pd[All]

Dimensions are halved at each level:

pd["ImageDimensions"]

Lowpass pyramid of a 3D image:

img=ExampleData[{"TestImage3D","CTengine"}];

pd=ImagePyramid[img]

View all image levels:

pd[All]

pd["ImageDimensions"]

Lowpass pyramid of a partially transparent image:

img = ;

ImageMeasurements[img,"Transparency"]

ipd=ImagePyramid[img,"Gaussian",4]

ipd[All]

OpenersExampleSubsection1(Spacer1)Parameters  (4)

The default lowpass kernel applied in each level before downsampling is the Gaussian kernel:

image=;

pd=ImagePyramid[image,"Lowpass"];

pd[All]

pd["LowpassKernel"]

Use a binomial kernel instead:

pd=ImagePyramid[image,{"Lowpass",{1,4,6,4,1}/16}];

pd["LowpassKernel"] //MatrixForm

Use a box kernel:

pd=ImagePyramid[image,{"Lowpass",{1,1,1}/3}]

pd["LowpassKernel"]//MatrixForm

Use a Gaussian kernel with standard deviation σ equal to half the downsampling factor a:

a=2;σ=a/2;
pd=ImagePyramid[
image,
{"Lowpass",GaussianMatrix[{{Automatic},σ}]},
∞,
a
]

pd[All]

pd["LowpassKernel"]//MatrixForm

Specify the number of levels to be returned:

pd=ImagePyramid[,"Lowpass",4]

pd[All]

Specify an image size that is smaller than or equal to the smallest image in the pyramid:

pd=ImagePyramid[,"Lowpass",{50,50}]

This pyramid has two levels. The next pyramid level of size 50×38 would have been smaller than 50×50:

pd["ImageDimensions"]

The default downsampling factor between successive levels is 2:

image=;
pd=ImagePyramid[image]

pd["ImageDimensions"]

Specify a downsampling factor of 5:

pd=ImagePyramid[image,"Lowpass",∞,5]

pd["ImageDimensions"]

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection3(Spacer1)Padding  (1)

The default padding is "Reversed":

image=;

pd=ImagePyramid[image]

pd[All]

Use "Fixed" padding instead:

pd=ImagePyramid[image,Padding->"Fixed"]

pd[All]

Use red padding:

pd=ImagePyramid[image,Padding->Red]

pd[All]

OpenersExampleSection3(Spacer1)Applications  (6)

OpenersExampleSubsection4(Spacer1)Efficient Image Viewer  (1)

Convert a large image into a pyramid for faster viewing:

img=ExampleData[{"TestImage","Volubilis"}];

pd=ImagePyramid[img,"Gaussian"]

View the image with width 320:

ImageResize[InverseImagePyramid[pd,Automatic,{320}],{320}]

Compare the timings for image retrieval:

ImageResize[InverseImagePyramid[pd,Automatic,{320}],320];//RepeatedTiming

ImageResize[img,320];//RepeatedTiming

OpenersExampleSubsection5(Spacer1)Multiscale Feature Detection  (3)

Apply a gradient filter at several scales simultaneously:

img = ;

pyramid=ImagePyramid[img,"Gaussian",4]

pyramidG=ImagePyramidApply[img|->GradientFilter[img,1.4],pyramid];

Reconstruct assuming a Laplacian pyramid to add up features extracted from all levels:

InverseImagePyramid[pyramidG,"Laplacian"]//ImageAdjust

Alter pyramid levels and type to detect mountain ridges at all scales:

img = ;

pyramid=ImagePyramid[img,"Gaussian",5]

ridgePyr=ImagePyramidApply[RidgeFilter,pyramid]

Reconstruct assuming a Laplacian pyramid to add up features extracted from all levels:

InverseImagePyramid[ridgePyr,"Laplacian"]//ImageAdjust

Perform a multiscale saliency filtering:

img = ;

Apply (RefLink[ImageSaliencyFilter, paclet:ref/ImageSaliencyFilter]) to an image:

ImageSaliencyFilter[img]//ImageAdjust

Apply saliency filter to all levels of the image pyramid to get a multiscale result:

pd=ImagePyramid[img,"Gaussian",3];

pdSaliency=ImagePyramidApply[ImageSaliencyFilter,pd];

Use Laplacian reconstruction to add up filter responses at all levels:

InverseImagePyramid[pdSaliency,"Laplacian"]//ImageAdjust

OpenersExampleSubsection6(Spacer1)Image Effects  (2)

Compute a bandpass pyramid:

pyr=ImagePyramid[,"Bandpass"]

Extract, negate and reinsert the three bottom levels of the image pyramid:

pyr[1;;3]=Map[-#&,pyr[1;;3]]

Reconstruct the image pyramid to exhibit the visual effect:

InverseImagePyramid[pyr]

Merge two images at just one scale:

{apple, orange}={, };

splitMerge[i1_Image,i2_Image]:=
 With[{c = Floor[1/2 First@ImageDimensions[i1]]},
ImageAssemble[{{ImageTake[i1,All,{1,c}],ImageTake[i2,All,{c+1,-1}]}}]]

splitMerge[apple, orange]

Merge the two images at all scales:

pyramids=Map[ImagePyramid[#,"Laplacian",{2,2}]&,{apple, orange}];

pFruit=ImagePyramidApply[splitMerge,pyramids]

InverseImagePyramid[pFruit]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

Images with constant alpha-channel result in Laplacian image pyramids that appear to be empty:

img = ;

ImageMeasurements[img,"Transparency"]

ipd=ImagePyramid[img,"Laplacian",4];

All pyramid levels except the last one will have an alpha channel equal to 0 and appear invisible:

ipd[All]

The image reconstruction works, since the data in the color channel is present and the alpha channel of the fully opaque last level contributes to the correct alpha channel for the reconstructed image:

InverseImagePyramid[ipd]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[InverseImagePyramid, paclet:ref/InverseImagePyramid])  ▪  (RefLink[ImagePyramidApply, paclet:ref/ImagePyramidApply])  ▪  (RefLink[DiscreteWaveletTransform, paclet:ref/DiscreteWaveletTransform])  ▪  (RefLink[ImageResize, paclet:ref/ImageResize])  ▪  (RefLink[GaussianFilter, paclet:ref/GaussianFilter])  ▪  (RefLink[LaplacianGaussianFilter, paclet:ref/LaplacianGaussianFilter])  ▪  (RefLink[Upsample, paclet:ref/Upsample])  ▪  (RefLink[Downsample, paclet:ref/Downsample])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Creating & Importing Images, paclet:guide/CreatingAndImportingImages])}})}})