You are on page 1of 6

04/01/2013

Digital Slides Slide s from digital im age s from 1.20, own lab, rush se rvice www.digital-slide s.co.uk Image Registration Autom atic im age re gistration software . Multi-m odal. Fre e trial. www.dualalign.com Polaris Sensor Tech. Polarim e try, O ptical Se nsing 3-D Display, Im age Proce ssing www.PolarisSe nsor.com

Home Adobe Photoshop Freebies Inspiration


Search adobe, tutorials, news.

Subscribe via RSS | Get E-mail Updates | Follow us on Twitter

Convolution Matrix
September 4th, 2006 by admin Posted in ActionScript, Macromedia Flash

SpecTIR
www.spectir.com Hyperspectral remote sensing data collection and analysis

Check out these the best Premium WordPress Themes

Convolution Matrix
Flash 8 introduces some very powerful tools for manipulating bitmaps at the pixel level. Included in this list of tools is flash.filters.ConvolutionFilter. ConvolutionFilter combines pixel data in a bitmap with data from neighboring pixels to produce a given result. Having control at the pixel level allows you to produce a wide array of effects on a bitmap. These include things like blurring, beveling, embossing, sharpening, and more. All are possible using ConvolutionFilter.
www.adobetutorialz.com/articles/1988/1/Convolution-Matrix

Stumble Submit

1/6

04/01/2013

Convolution Matrix

Unlike Matrix and ColorMatrixFilter, ConvolutionFilters matrix does not have a set number of rows and columns. The number of rows and columns depend on the type and strength of the effect you are trying to achieve. In a nutshell, ConvolutionFilter looks at each and every pixel in a source bitmap. As it does this, it uses the center value in the matrix as the value of the current pixel being manipulated. For example, in a 5 x 5 matrix, the center value is at (2, 2). It then multiplies the values from the matrix to the surrounding pixels and adds the resulting values for all pixels to get the value for the resulting center pixel. Here is the formula used on a 3 x 3 matrix convolution:
dt(,y =(sc(-,y1 *a +scx y1 *a.. s x ) (r x1 -) 0 r(, -) 1.. scx y1 *a +sc(+,+)*a)/dvsr +ba r(, +) 7 r x1y1 8 iio) is

As you can see, for the pixel located at (x, y), ConvolutionFilter with a 3 x 3 matrix takes the pixel (x1, y1) and multiplies it by the value in the matrix located at (0,0), and then adds the pixel (x, y1) multiplied by the value in the matrix at (0,1), and so on until all of the matrix values have been multiplied by the corresponding pixel value. (This is done for each color channel.) Finally, it takes that total, divides by the value of divisor, and adds the value of bias. Obviously the larger your matrix, the longer this process takes. To apply a convolution matrix, you can pass a matrix along with the number of rows and columns into the ConvolutionMatrix constructor, as follows:
ipr fahflesCnouinitr mot ls.itr.ovltoFle; / Stu or33mti: / e p u x arx vrmtAry=[101 a a:ra ,,, 010 ,,, 101] ,, ; / Tl teCnouinitrta ti i a3rw 3clm mti / el h ovltoFle ht hs s o, oun arx / Ps temti i a wl: / as h arx n s el vrcnMtCnouinitr=nwCnouinitr33mt; a ova:ovltoFle e ovltoFle(,,a) ci.itr =[ova] lpfles cnMt;

The following examples illustrate some convolution matrices. A useful exercise is to look at the matrix values and guess the effect they might produce on the image. Figure 10 shows the original photo.

Figure 10. Original image In Figure 11, the pixel being affected gets its original value multiplied by 5, while the pixels immediately above, below, to the left, and to the right are multiplied by 1, with the resulting values added together and multiplied by the affected pixel to produce a new value for that pixel. The resultant effect is that there is an increase in contrast between neighboring pixels. If neighboring pixels have values that are quite similar, those pixels remain fairly similar. However, the greater the original color value difference between pixels, the greater the resulting difference will be.

2/6

04/01/2013

Convolution Matrix

Figure 11. A sharpening effect Figure 12 shows the value of the affected pixel having its value added to that of each of its surrounding eight pixels. You can probably guess that this mashing of values results in a blur effect.

Figure 12. A blurring effect By looking at the matrix in Figure 13, you can see that the result is trickier to guess than in the previous examples. The affected pixel tends to become closer in value to the pixels near the bottom right and further away in value than the pixels at the top left. The result is an embossed effect with the light source appearing to emanate from the top left.

Figure 13. An embossing effect As you can see, having a basic understanding of matrices allows you to produce some powerful effects using the new ConvolutionFilter. In the convolution demo file that accompanies this article, you can play directly with values in a matrix and see the resulting convolution effect on the image. Play with the following demo to see the changes for yourself:

www.adobetutorialz.com/articles/1988/1/Convolution-Matrix

3/6

04/01/2013

Convolution Matrix

Where to Go from Here


Flash 8 was truly one of the biggest releases in Macromedias product history. It provides developers with a very granular level of control in several different areas. Matrices provide a powerful means of doing this type of manipulation. This article serves as a primer for people interested in gaining a better understanding of matrices. I recommend playing with these matrix values to see the ensuing results. Thats often where the real learning happens.

Windows 8 Touch Apps


intuiface-presentation.com/ Build your own multi-touch presentations on Win8. Free trial!

If you enjoyed this article, please consider sharing it!

www.adobetutorialz.com/articles/1988/1/Convolution-Matrix

4/6

04/01/2013

Convolution Matrix

Advertise Here

adobetutorialz trn Facebook


Thch 6.105 6,105 ngi thch adobetutorialz.

N abeel

Deb

Rathanak

V ahid

M ino

Rey haan

Khll

A lessandra

M uhamad

A ungmy o

P lugin x hi ca F acebook

China manufacturers Custom Signs Royalty Free Images Domain Name Download Adobe Photoshop online photo retouching services
www.adobetutorialz.com/articles/1988/1/Convolution-Matrix 5/6

04/01/2013

Convolution Matrix

Hughesnet Gen4 Free Stock Photos and Images Adobe Connection Flash Web Sites Baby Boy Clothes

Categories
Acrobat Family Adobe Photoshop Adobe Technologies Creative Suite Family Design Software Digital Imaging Digital Photography Software Freebies Inspiration Macromedia Products Photoshop Plugins Print and Web Publishing Video and Audio

About / Contact Us Popular


Contact Us Advertise with us Submit a bug report Privacy Policy

Subscribe Stats
Subscribe via RSS Get E-mail Updates Follow us on Twitter

searches
Merry Christmas Saint Valentine Wallpapers Photo Effects Web Layouts

2006-2011 Adobetutorialz. All rights reserved. a Media Temple company

www.adobetutorialz.com/articles/1988/1/Convolution-Matrix

6/6

You might also like