Blur Algorithm ?

Started by
5 comments, last by NinjaCross 23 years, 10 months ago
Hey guys ! I''ve goy a little question. How can I make an algorithm that make the blur-effect on a bitmap ?? I need for a normal blur algorithm, but if it''s possible, a Gaussian-Blur once If you don''t know the specyfic algorithm, but you know WHERE i can find some informations about it, don''t hesitate to write ! Any sentence is appreciated ! Thankyou in advance. //------------- Making Funny Garbage Codes on http://members.xoom.it/NinjaCross
//-------------A straight line may be the shortest distance between two points, but it is by no means the most interesting.http://members.xoom.it/NinjaCross
Advertisement
I don''t know how to do a gauss blur But here''s a (too) simple explaination:

For every pixel take the value of it''s neighbours add them all up, and divide by the amount of neighbours.
In other words calc the average...

Yah, for pixel x in the diagram (below) Take pixels 1-8 and average it with the pixels current value.

[1][2][3]
[4][x][5]
[6][7][8]

If you want the pixel x to resemble itself twice as much as as the surrounding pixels, simple add 1-8 together and divide by 16 then add x divided by 4. I think that''s right? Well play around... but averaging is the idea, different special blurs are just tweaks like this one, try searching for gaussian blur on the net...
See ya,
Ben

P.S. Blurring is almost always to slow for in game speeds... It takes like 9 - 12 times more time than a normal blit... But you could do cool menu stuff, or pre-blur something for ingame, or if you use it sparengly like software alpha blending...
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
how would you blur a bitmap with only a 256-color set-in-stone palette?
http://fakemind.com
hmmm.... well is the pallete an "optimized" pallete or is it a gradule order of some sort like 8bpp? If it''s "optimized" or rearanged order specially for each image, then I''d say your hooped, but if not there may be a way, just experiment....
- Ben
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
quote:Original post by Jeremiah

how would you blur a bitmap with only a 256-color set-in-stone palette?


Convert to 24-bit internally, blur as described above, then for each blurred pixel find the entry in the palette that most closely matches the new pixel. The more evenly distributed your palette is, the better this would work. You couldn''t really do this in real-time without some serious optimization, though

I wrote ASM code that does this kind of blurring stuff in 8-bit or 24-bit fullscreen. (The 8-bit requires a smoothly shaded palette to look any good). I also did a 15-bit version that I never got around to testing, and a 16-bit version that didn''t quite work (very strange problem).

It''s reasonably fast, but still too slow to be used on a high res. or along with any other CPU munching code. The main problem I find is that to muck around with a direct draw surface at a pixel level it ought to be in system memory, and BLTing from system memory to video memory is slow (with a capital S). I''m going to try the DMA stuff in Dx7, hopefully this will speed it up a bit.

George.

"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"

George. F"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"

This topic is closed to new replies.

Advertisement