Anonymous user
Image convolution: Difference between revisions
link to wikipedia article
m (→{{header|Phix}}: added syntax colouring, marked p2js incompatible) |
(link to wikipedia article) |
||
Line 1:
{{task|Image processing}}
One class of image digital filters is described by a rectangular matrix of real coefficients called [https://en.wikipedia.org/wiki/Kernel_(image_processing) '''kernel'''] convoluted in a sliding window of image pixels. Usually the kernel is square <math>K_{kl}</math>, where <i>k</i>, <i>l</i> are in the range -<i>R</i>,-<i>R</i>+1,..,<i>R</i>-1,<i>R</i>. <i>W</i>=2<i>R</i>+1 is the kernel width.
The filter determines the new value of a '''grayscale image''' pixel P<sub><i>ij</i></sub> as a convolution of the image pixels in the window centered in <i>i</i>, <i>j</i> and the kernel values:
<blockquote>
Line 7 ⟶ 9:
</blockquote>
'''Color images''' are usually split into the channels which are filtered independently. A color model can be changed as well, i.e. filtration is performed not necessarily in RGB. Common kernels sizes are 3x3 and 5x5. The complexity of filtrating grows quadratically ([[O]](<i>n</i><sup>2</sup>)) with the kernel width.
'''Task''': Write a generic convolution 3x3 kernel filter. Optionally show some end user filters that use this generic one.
|