hi guys!i'm new here and i guess that i will learn a lot reading deep into this forum

but now a question.. i'm trying to build a library to handle the animation and effects of my applets and i'm getting some problems with performance .. i'm using Java2D api to avoid problem of compatibility and i'm becoming crazy finding a fast way to implement a blur algorithm that i will use in animation.. the first try was with a ConvolveOp class but it's too much slow with a 8x8 kernel...

I've implemented the second one before, operating on an int[] raster. I think the fastest I managed to get it after a couple of days of optimisation was 20 blurs per second of 640x480 RGB on a 2006-era mid-range desktop.

I've implemented the second one before, operating on an int[] raster. I think the fastest I managed to get it after a couple of days of optimisation was 20 blurs per second of 640x480 RGB on a 2006-era mid-range desktop.

Even faster if you cast the DataBuffer to a DataBufferInt, and use DataBufferInt#getData() to obtain the underlying int[].You are then manipulating the Image's data array directly - no copying necessary.

Obviously you need to ensure your BufferedImage is of a suitable type.

but i still don't understand exactly the algorithm... for example what means "each destination pixel is simply the average of a short horizontal line of pixels in the source image"?means the average of all color component?

(i'm trying to implement the second trick because is more flexible i think..)

but i still don't understand exactly the algorithm... for example what means "each destination pixel is simply the average of a short horizontal line of pixels in the source image"?means the average of all color component?

Why? You're going to get your cache misses in the transpose operations rather than the blurring, aren't you?

Lets say the image is 1024 pixels wide, so each scanline is exactly one page (4K).

If you blur 'radius' is 4 pixels, you need 4+1+4=9 pixel reads for each pixel write. When reading/writing columns, you have to continuously read from 9 different pages for each pixel write. Something tells me the CPU (or JVM) won't find the 'fast path' for such code.

Anyway, I'll benchmark it properly.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

This is 8 years old code, so please don't shoot me.I know there is a better way to do this (without using a buffer image of the same size), but this works.At least for blurring integer data, easily extendable to ARGB.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org