IMCONV

Purpose:

Convolves an RGB image with a 2D filter kernel.

Syntax:

IMCONV(image, k, "shape")

 

image

-

An array, the input image.

k

-

An array, the filter kernel.

"shape"

-

Optional. A string, the output shape flag. Valid options:

"full"

:

full convolution output

"same"

:

output is a section of the same size as image (default)

"valid"

:

output only includes values not computed with zero-padding

Returns:

An image, the convolved result.

Example:

W1: readimage(gethome + "data\kasha.jpg");setaspect(-1);scalesoff;

 

W2: {{-1, -4, -1},

     {-4, 26, -4},

     {-1, -4, -1}}/6;

 

W3: imconv(w1, w2);setaspect(-1);scalesoff;

 

W1 contains a JPEG image. W2 contains the 2D filter kernel, a sharpening filter. W3 displays the result where the details of the original image are sharper.

 

Remarks:

IMCONV performs the two-dimensional linear convolution in the time domain.  For an image I[x, y] and a kernel function f[x, y], the 2D linear convolution c[x, y] is defined as:

 

 

Values outside the dimensions of an array are assumed to be zero.

 

Unlike CONV2D, IMCONV process each R, G and B component of an image separately and combines the result. If the image is black and white, IMCONV is identical to CONV2D.

 

For the full convolution, the output size is:

 

 numrows(image) + numrow(k) - 1  x  numcols(image) + numcols(k) - 1

 

If shape is "same", the output array has the same size as image. This option is useful to force the output to the same size as the input for image processing applications.

 

If shape is "valid", the output size is:

 

numrows(image) - numrows(k) + 1 x numcols(image) + numcols(k) + 1

 

if the size of image is larger than k, otherwise an empty array is returned. This option returns the section of the full convolution where both arrays fully overlap during the convolution computation such that no outside the boundary assumed zero values are used.

See Also:

CONV

CONV2D

FCONV2D

FFT2

IMINTERP

NONLIN2D

READIMAGE

SOBEL