Convolves an RGB image with a 2D filter kernel.
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:
|
An image, the convolved result.
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.
IMCONV performs the two-dimensional linear convolution in the time domain. For an image
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.