({{, (RefLink[ImageConvolve, paclet:ref/ImageConvolve])[image,ker] 
gives the convolution of image with kernel ker.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ImageConvolve, paclet:ref/ImageConvolve]) performs the convolution operation on an image. It is a spatial filtering function used to apply any finite-dimensioned filter, also known as a finite impulse response (FIR) filter, to an image.

(RefLink[ImageConvolve, paclet:ref/ImageConvolve]) works with 2D and 3D images, operating separately on each channel.

The convolution kernel ker is given as a two-dimensional numerical matrix, a one-channel image or a multichannel image with the same number of channels as image.

(RefLink[ImageConvolve, paclet:ref/ImageConvolve])[image,ker] by default gives an image of the same dimensions as image.

(RefLink[ImageConvolve, paclet:ref/ImageConvolve]) takes a (RefLink[Padding, paclet:ref/Padding]) option. The default setting is (RefLink[Padding, paclet:ref/Padding])->"Fixed".

With a setting (RefLink[Padding, paclet:ref/Padding])->(RefLink[None, paclet:ref/None]), (RefLink[ImageConvolve, paclet:ref/ImageConvolve])[image,ker] normally gives an image smaller than image.

(RefLink[ImageConvolve, paclet:ref/ImageConvolve]) gives an image of a real type.

OpenersPrimaryExamplesSection(Spacer1)Examples  (17)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Smooth an image by convolving with a square kernel:

ImageConvolve[,BoxMatrix[1]/9]

Convolve a grayscale image with a Sobel mask to detect vertical edges:

ImageConvolve[,(({{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}}))]

OpenersExampleSection1(Spacer1)Scope  (5)

OpenersExampleSubsection0(Spacer1)Data  (2)

Convolve a binary image:

ImageConvolve[,(({{-2, 1, 1}, {-1, 1, 2}, {-2, -2, 1}}))]

Smooth a 3D image:

ImageConvolve[,GaussianMatrix[{{3,3,3}}]]

OpenersExampleSubsection1(Spacer1)Parameters  (3)

Blur an image with a horizontal kernel:

ImageConvolve[,ConstantArray[1,{1,21}]/21.]

Use a vertical kernel:

ImageConvolve[,ConstantArray[1,{21,1}]/21.]

Blur a 3D image in the vertical direction only:

ImageConvolve[,ConstantArray[1,{11,1,1}]/11]

Blur in the horizontal direction only:

ImageConvolve[,ConstantArray[1,{1,11,11}]/121]

OpenersExampleSection3(Spacer1)Options  (4)

OpenersExampleSubsection2(Spacer1)Padding  (4)

By default, a "Fixed" padding is used:

ImageConvolve[,GaussianMatrix[10]]

Pad with zero:

ImageConvolve[,GaussianMatrix[10],Padding->0]

Use reversed padding:

ImageConvolve[,GaussianMatrix[10],Padding->"Reversed"]

No padding results in a smaller image:

ImageConvolve[,GaussianMatrix[15],Padding->None]

OpenersExampleSection4(Spacer1)Applications  (3)

Apply horizontal blur:

ImageConvolve[,ConstantArray[1/20,{1,20}]]

Find edges using Robert's method:

i=;

{f1,f2}=ImageConvolve[i,#]&/@{ {{1,0},{0,-1}},{{0,1},{-1,0}}}

(Sqrt[(f1^2)+(f2^2)])//ImageAdjust

Unsharp masking using (RefLink[ImageConvolve, paclet:ref/ImageConvolve]):

i=;
2i-ImageConvolve[i,BoxMatrix[1]/11]

OpenersExampleSection5(Spacer1)Properties & Relations  (3)

Convolution with a constant filter has an effect equivalent to mean filtering:

{ImageConvolve[,BoxMatrix[3]/49.],MeanFilter[,3]}

Relation with (RefLink[ListConvolve, paclet:ref/ListConvolve]):

image=RandomImage[];
kernel=RandomReal[1,{5,5}];

ImageData@ImageConvolve[image,kernel,Padding->"Fixed"]==ListConvolve[kernel,ArrayPad[ImageData[image],Floor[Dimensions[kernel]/2],"Fixed"]]

(RefLink[ImageConvolve, paclet:ref/ImageConvolve]) gives an image of a real type.

ImageType[ImageConvolve[Image[DiskMatrix[23,81],"Bit"],RandomReal[1,{2,1}]]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ImageDeconvolve, paclet:ref/ImageDeconvolve])  ▪  (RefLink[ListConvolve, paclet:ref/ListConvolve])  ▪  (RefLink[ImageCorrelate, paclet:ref/ImageCorrelate])  ▪  (RefLink[GaussianFilter, paclet:ref/GaussianFilter])  ▪  (RefLink[GradientFilter, paclet:ref/GradientFilter])  ▪  (RefLink[DiskMatrix, paclet:ref/DiskMatrix])  ▪  (RefLink[BoxMatrix, paclet:ref/BoxMatrix])  ▪  (RefLink[GaussianMatrix, paclet:ref/GaussianMatrix])  ▪  (RefLink[ImageEffect, paclet:ref/ImageEffect])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Image Processing, paclet:tutorial/ImageProcessing])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Image Processing & Analysis, paclet:guide/ImageProcessing])}, {▪(RefLinkPlain[3D Images, paclet:guide/3DImages])}, {▪(RefLinkPlain[Image Filtering & Neighborhood Processing, paclet:guide/ImageFilteringAndNeighborhoodProcessing])}, {▪(RefLinkPlain[Fourier Analysis, paclet:guide/FourierAnalysis])}, {▪(RefLinkPlain[Feature Detection, paclet:guide/FeatureDetection])}})}})