<a id="easyimage-linear-filtering"></a>

# Linear Filtering

The convolution functions use linear combinations of neighboring pixels to highlight some features in an image.

![](assets/images/easyimage/linear_filter_1.webp)![](assets/images/easyimage/linear_filter_2.webp)
* All the convolution functions can be destructive, meaning that the destination image overwrites the source image.
* **eVision** offers 2 ways of doing convolutions:
  * Use a predefined method with a predefined filter, and in some cases, a kernel size.
  * Create your own [`EKernel`](../../../doxygen_cpp/classeVision_1_1EKernel.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EKernel.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EKernel.html) and use the function [`EasyImage::ConvolKernel`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a6593a0fdb08e332d6534091c608e115c) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#aee2a47d278abc285097c7c300998a333) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a285fdb54dabd903e9bf0a6859e44a347).

<a id="easyimage-linear-filtering-predefined"></a>

## Predefined Filters

The available predefined filters are:

| * [`EasyImage::ConvolLowpass1`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a7765c0159a6676c9c9b52cddbea9b5d5) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a3ae4695b4d48a7c0d839e907922f5002) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#afeaba983dcb768340492c76e508dd73f)<br/>* [`EasyImage::ConvolLowpass2`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a89cb0ab1ae7c5dda3a75999a6b655c87) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a5f100be9bb61458e277c094fe6fb378c) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a71caa690c82d6ad2ce6ab44d23594565)<br/>* [`EasyImage::ConvolLowpass3`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#afc99a4eb8ba969b2b1ad6eabb298dbb2) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a63a0cccd3fc1dcb5428d1ba23d94ab81) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#af97eca8d7b7bea1d4b0f1c5f9bca39b1)<br/>* [`EasyImage::ConvolHighpass1`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a5797d794d53579f1965684d3ccd754ef) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a13f8f1be01a991d808777e238635efba) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a4084f33f667d106f7f1390b5eff2f0af)<br/>* [`EasyImage::ConvolHighpass2`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a13c128a6c3177a7bacf43cfbb695cc64) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#aaad04a76fe725dec26cae5a8764d208c) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a7ddb5166fddd18e21fbbaf6916049ced)<br/>* [`EasyImage::ConvolGradient`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#acda51de82a8e63b83043a8548eb2e6a1) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#aa989946fcea5412cf1036255131794d5) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a50bd495bd2a6efb7eab1d431f1d07b1e)<br/>* [`EasyImage::ConvolGradientX`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a148da30b709f387d148f506dc739a350) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a90e911853f10c872fd0c0ff4186bf314) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#ad5277d754d4693a2a1e0ccc232096b8b)<br/>* [`EasyImage::ConvolGradientY`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#aadeed40790375c87f40666e8b0ce54c5) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#add90c18a16abafb06cfb75a50c09b0e3) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a8140478e308239ce02aef574fa38c32a)<br/>* [`EasyImage::ConvolLaplacian4`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a840e21cf920ddd43737bd5d289b56258) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a0f0f0bd20854f3e31fccb1ebffcb5f4b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a5c05b8c783bd30ce9d4e64b0bbf45595)<br/>* [`EasyImage::ConvolLaplacian8`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a70a0524786918b183a7c0e3c76370e95) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a44b987f8f302ab68b8c14d2acdb2eb1b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a209a7eb22f9a0372c5e71c762bf0ba16)<br/>* [`EasyImage::ConvolLaplacianX`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a545c615fea542c70d138bbdeab165af4) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a80e5606aaa2d07608c534f085f517e77) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a9f2362c4e3c7a25aee8cba2d777c53ca)<br/>* [`EasyImage::ConvolLaplacianY`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#aa0e338996d7f32305892994f14559799) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a91677a819e80ec4b45ee977519b75c01) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#ad4a7be5a97cf7fb9446099675bfcca5f)   | * [`EasyImage::ConvolPrewitt`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a2aeb4cc8162bb830de26fb6ad006172a) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#ab65e1aafd6e01b5f37f6f4c4738ba364) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#ad6d9f5eaabbe5f22023f21fe6fab7402)<br/>* [`EasyImage::ConvolPrewittX`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#abfc18cce8cc5370e21347d9f80f41c9a) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a989d2bc754f6b5633d0bbf6a374a2bcd) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a7c334c08a885469b9c3d6ab385eab00a)<br/>* [`EasyImage::ConvolPrewittY`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a915589fd0708d66db877a2d466abcde4) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a0d53ad5bfa89f7adb64323f1486ebaa3) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#acf32db0967c05769bde13dbbb2e73b5c)<br/>* [`EasyImage::ConvolSobel`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a18a27f58923cfd5c0b42b480f0ab295a) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#af6d3bc69a09f77a46afac5fad5dd60a6) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#aebb1262c2d49123c96d47cf53d13c315)<br/>* [`EasyImage::ConvolSobelX`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a5cfd132efdb665bba7f81f60ae6586b2) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a04eb8dec289036fcaec01047b8832eb6) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#ace58622dc123d74e66a5e59f91ae7319)<br/>* [`EasyImage::ConvolSobelY`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a0d362d88c9d13735615d103e247a7d89) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a90e819be20e871b3f928a1bca5e6c917) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a17dd807897cca882a1370311123a92e0)<br/>* [`EasyImage::ConvolRoberts`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a3cffbd5fe3b682fa8ea6c714d9317565) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a42c381cf9fa28e9f94f5355eea1a04ad) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#aa679dfad4ceebe018b3baa2d5b45c75b)<br/>* [`EasyImage::ConvolUniform`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#aaa8ce68270a0bfd82cd6e184d5f2d6ed) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a95b6b0594caa516696017badeb4c8051) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a377cf284f159e96b37692a2096df3afd)<br/>* [`EasyImage::ConvolGaussian`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a2427f87dc5801fffd97d8ace0571f3aa) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a38a4452f47c3dce1c31881880a641c39) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#ae0799598485b88dd6c2eab89ec9c062b)<br/>* [`EasyImage::ConvolGabor`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a42b3c6e43b7ca4625f4e7da53306afaf) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a5952df1ea12e591163128579510007fe) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a2dd9a94d3104a8505bbaf35ed9ba73b2)   |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

<a id="easyimage-linear-filtering-custom"></a>

## Customized `EKernel`

When you use your own kernel:

* You can choose the width and height of the kernel.
  * Use [`EKernel::SetKernelData`](../../../doxygen_cpp/classeVision_1_1EKernel.html#a65ab0e71f70162a5774f56a59155f098) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EKernel.html#a8a3bad599fa8bb5e2c91f0a725e88b5d) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EKernel.html#ad9b2d064ab88a86043f92b6e81319dcc) to fill the convolution coefficients.
* **eVision** automatically normalizes the kernel coefficients so that their sum is 1.
  * If you define a [`EKernel::SetGain`](../../../doxygen_cpp/classeVision_1_1EKernel.html#a767a037f41422626cae0905a3bf181ce) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EKernel.html#a0e6dc2307eb27ea4a576a1ad69c0d552) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EKernel.html#a5c8325cc5c3d810700fb44b4a63d8184) (multiplying all resulting pixels by that value) and an [`EKernel::SetOffset`](../../../doxygen_cpp/classeVision_1_1EKernel.html#a31798159a4541c193b5827dcf1e116c5) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EKernel.html#a738c8b8ddfdd657c6b1d977893178182) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EKernel.html#a3dabceb323e5dc7b057c85d8c3dc4e48) (adding that value to all resulting pixels), they are applied after that normalization.
  * Note that using any gain other than 1 can lead to a saturation in the resulting image and an overflow or an underflow during the internal calculations.
* To rectify any value (to keep only the positive ones for instance), set an [`EKernelRectifier`](../../../doxygen_cpp/namespaceeVision.html#afad3db17c1a46cd1cf56843585ce132d) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#ac35f7d4b783bccb050cf319fa712bf9f) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EKernelRectifier.html).
* The outside value is used for the border calculations (when the kernel needs values from out of the image on the border of the image to compute the result).
* Another way to create a kernel is by giving the constructor an [`EKernelType`](../../../doxygen_cpp/namespaceeVision.html#a7dc90b4f33628bb10242eecb1887344b) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a4efdde8ceca649b737f660f01c083e66) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EKernelType.html). This is quite similar to the way of doing a convolution with a predefined filter.

<a id="easyimage-linear-filtering-quick-links"></a>

## See Also

Easy to understand, ready to copy code snippets.

Conceptual guide to choosing and applying spatial and temporal noise reduction.

Frequency-selective convolution for texture analysis using the Gabor wavelet.
