Dark Bit Factory & Gravity
PROGRAMMING => General coding questions => Topic started by: va!n on December 18, 2008
-
is there any way to resize an image (for example 800x600) down to 200x150 where the resized image looks smooth (like AA) in realtime? I saw that there are different algos for doing this. What about Bicubic or does someone has another faster way for doing this?) thx.
-
imho, even with a simple box filter, the reduction would smooth the image anyway :)
I don't have any idea about the real-time consideration though :S
-
Have a look at this video which explains a very clever
algo:
http://www.youtube.com/watch?v=qadw0BRKeMk (http://www.youtube.com/watch?v=qadw0BRKeMk)
-
@benny:
thanks! i know this video and its really awesome!
I am just searching for a fast source that i can use ;)
The document has been removed or still no longer exist... mhhh..
http://www.faculty.idc.ac.il/arik/SCWeb/imret/index.html (http://www.faculty.idc.ac.il/arik/SCWeb/imret/index.html)
-
Which filter is "best" for you depends very much on your input-material and what you want to achieve.
Since you're oversampling and using some sort of lowpass-filter you'll inevitably get something "smooth (like AA)".
However, digital filter-design is a large field and requires some serious knowledge of signal processing.
So just do what Hezad said and try a simple box-filter first.
I am just searching for a fast source that i can use
I'm sure you won't need a source to add 4x4 numbers...
-
@hellfire:
also when having 400x400 and want to scale down to 100x100 for eaxmple, i have to do following, right?
A B C D x x x x x x
E F G H x x x x x x
I J K L x x x x x x
M N O P x x x x x x
x x x x x x x x x x
x x x x x x x x x x
each char is representing one pixel (RGB)... to resize it down with something like AA, the math would be...:
newpixel = (( A + B + C + D + E + F + G + H + I + J + K + L + M + N + O + P ) / 16 )
Btw, i think i have to do this for each R G B channel ^^
Instead using Div16 i could speed it up by using shift >>4... Wonder if this would be really be fast enought... i will try this out...
-
i have to do following, right?
right.
Wonder if this would be really be fast enought
You're reading each pixel of your input-image exactly once and do a single addition (okay, and some bit-fiddling to extract rgb). Can't get much cheaper than that...
If you really need it to be faster, I probably have some mmx-stuff somehwere to do it.
However, if you're processing rather high-resolution images in software, it was very likely a lot of more work to generate the image than to downscale it; you also might want to consider if you can't generate the image in a way that does not (or less) require downsampling.
-
@hellfire:
thanks for your offer... i managed it to get it work with a good looking result i think and the speed it ok for the stuff where i need it for ;)