REBOL Technologies

New Convolve Effect in REBOL/View 1.3.2

Carl Sassenrath, CTO
REBOL Technologies
15-Dec-2005 0:56 GMT

Article #0236
Main page || Index || Prior Article [0235] || Next Article [0237] || Post Comments || Send feedback

If you have not already done so, I invite you to check out the new convolve effect in the lastest release of REBOL/View. It's fun to try.

In a nutshell, the convolve effect implements a graphics convolution operation over an image. You can think of convolution as a sort of moving average over the nearby pixels of an image. Using it, you can create a wide range of image processing effects, such as blur, sharpen, edge detection, emboss, and more. So, it's a general image operator.

To see a demo, click on the Convolve icon in the REBOL viewtop (desktop) demos folder. Click on "Emboss 2" to see a heavy emboss operation.

Use the given images, or try it on your own images. Modify the matrix (at top right) or the other arguments to discover some of your own interesting effects.

To use convolve in your program, it is provided as a face effect that takes the form:

CONVOLVE matrix divisor bias grey-flag

convolve: [
    matrix [block!]    "Nine numbers that form a 3x3 matrix"
    divisor [number!]  "Scales the result"
    bias [number!]     "Adds to the luma of the pixel 0-255"
    grey-flag [logic!] "Converts to greyscale during the process"

Everything other than the matrix are optional. If not provided, the divisor uses a computed average value and the bias is zero.

Here is an example that shows how to create a custom effect, a sort of motion blur:

img: load-thru/binary
motion-blur: [
    0 0 1
    0 0 0
    1 0 0
view layout [box img effect reduce ['convolve motion-blur]]

Here is a deep emboss that uses the optional arguments:

deep-emboss: [
    2 0 0
    0 -1 0
    0 0 -1
view layout [
    box img effect reduce ['convolve motion-blur 1 128 true]

To use other effects, just take a look at the source code for the Convolve script mentioned above.

You can thank Richard "Cyphre" Smolak for this new convolve effect. Although an integer-based version has long been part of REBOL/View (to do the emboss effect), it was never exported. Richard's version also allows the decimal-based matrix and the extra arguments. (Richard also wrote the handy Convolve demo mentioned above.)

Post Comments

Updated 12-Mar-2024   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code