Author Topic: Need good algorithm of Magnification filter  (Read 7243 times)

0 Members and 1 Guest are viewing this topic.

Offline Emil_halim

  • Atari ST
  • ***
  • Posts: 248
  • Karma: 21
    • View Profile
    • OgreMagic Library
Hi all

Does any one know a good algorithm of Magnification filter of Image processing ?

To make it more simple , I really need a very high quality Mag Filter algorithm, just like the flash movie player, the DirectX filter is poor when compared with flash player.

Any help appreciated .   

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Need good algorithm of Magnification filter
« Reply #1 on: May 14, 2007 »
Are you by chance referring to a radial blur?

I'm not quite sure what you're asking here.
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Offline Emil_halim

  • Atari ST
  • ***
  • Posts: 248
  • Karma: 21
    • View Profile
    • OgreMagic Library
Re: Need good algorithm of Magnification filter
« Reply #2 on: May 14, 2007 »
Thanks Thygrion for your reply.

But not it is any blur effect , what I am asking for is , a Magnification algorithm that produce a good quality when we resize our Image.

When you have a small image and using DirectX Magnification filter the Image will has a poor Magnify , do the same thing with Flash Player you will notice that  Flash Player give a very high quality Image.

So I just asking for a  Magnification algorithm that similar to  Flash Player.

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Need good algorithm of Magnification filter
« Reply #3 on: May 14, 2007 »
Oh ok.

Well, this now becomes a matter of how things are rendered.

DirectX just stores images as just pixels, which is why you usually get a crappier resize.

What flash does is different entirely - flash is a vector-based program. So where DirectX draws lines of pixels, flash draws things such as ovals, rectangles, and lines.

You can see this in alot of flash cartoons - where all edges are well-rounded and don't "blur" with other pixels, because they aren't pixel-based. Vector graphics are object-based, and that's why flash has higher image quality.

Sorry if this is disappointing, but it's the truth.

Hope it helps.
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Need good algorithm of Magnification filter
« Reply #4 on: May 14, 2007 »
I agree with Thygrion there.

Thinking about your problem though, I don't think that there will be much chance of getting the image quality you are after.

Maybe you will need to work with bigger textures, or as Thygrion suggested using some sort of blur routine to try and disguise the pixelation a little?
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Emil_halim

  • Atari ST
  • ***
  • Posts: 248
  • Karma: 21
    • View Profile
    • OgreMagic Library
Re: Need good algorithm of Magnification filter
« Reply #5 on: May 14, 2007 »
thanks Thygrion , Shocky.

Yah , it is clear now why Flash Player has more quality than DirectX.

any way I have found a better  Magnification filter than DirectX , here is a link of it.

http://www.liimatta.org/fusion/filter/filter.html

It uses a bicubic algorithm , although it is not the same as Flash Player quality but it is better than DirectX.

BTW , where can I find the  vector-based  algorithm of ovals, rectangles, and lines?

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Need good algorithm of Magnification filter
« Reply #6 on: May 14, 2007 »
Some of the routines in the framework here ;

http://dbfinteractive.com/index.php?topic=1455.0

Would be suitable for you to use. There is also a cubic spline routine in there which could be useful.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Emil_halim

  • Atari ST
  • ***
  • Posts: 248
  • Karma: 21
    • View Profile
    • OgreMagic Library
Re: Need good algorithm of Magnification filter
« Reply #7 on: May 14, 2007 »
thanks Shocky.  :)

Already using these code , it is very useful routines.

But I need more similar Flash Player algorithm.

Anyway thank you again for your help , have a nice time with Jacob Baby.  :)

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Need good algorithm of Magnification filter
« Reply #8 on: May 14, 2007 »
Can you post a side-by-side comparison picture of what you have and what you'd like? (bmp)  There are tons of ways of producing the data to fill in the gaps between the real pixels.

Jim
Challenge Trophies Won:

Offline Emil_halim

  • Atari ST
  • ***
  • Posts: 248
  • Karma: 21
    • View Profile
    • OgreMagic Library
Re: Need good algorithm of Magnification filter
« Reply #9 on: May 15, 2007 »

Ok Jim, Here they are.

the poorest is DX one.

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Need good algorithm of Magnification filter
« Reply #10 on: May 15, 2007 »
Looks like this image was originally made in flash -- two circles; a grey one and one on top of it with a gradient fill pattern. If you would like vector-based graphics you should research rendering methods of lines with variable width, ovals, rectangles, and 2D vector math in general for rotation, scaling, etc.
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Offline Emil_halim

  • Atari ST
  • ***
  • Posts: 248
  • Karma: 21
    • View Profile
    • OgreMagic Library
Re: Need good algorithm of Magnification filter
« Reply #11 on: May 15, 2007 »

Yes ,  Thygrion , it is a Flash shape , I have searched for the vector graphics and found SVG (scalar vector graphics) but still search for open source SVG viewer to learn how it works.     

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Need good algorithm of Magnification filter
« Reply #12 on: May 15, 2007 »
Right, you're never going to find a bitmap scaling that will give you the result you want.  But if you go here
http://en.wikipedia.org/wiki/Scalable_Vector_Graphics there are lots of links at the end to SVG libraries which will definitely do what you want.

Jim
Challenge Trophies Won:

Offline Emil_halim

  • Atari ST
  • ***
  • Posts: 248
  • Karma: 21
    • View Profile
    • OgreMagic Library
Re: Need good algorithm of Magnification filter
« Reply #13 on: May 16, 2007 »

thanks Jim.

i have found a good library , it is Cairo , i will ues it.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Need good algorithm of Magnification filter
« Reply #14 on: May 16, 2007 »
Cairo does ovals / circles, true type fonts etc? :)

How easy is it to link and include something like that into a fb program?
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Emil_halim

  • Atari ST
  • ***
  • Posts: 248
  • Karma: 21
    • View Profile
    • OgreMagic Library
Re: Need good algorithm of Magnification filter
« Reply #15 on: May 16, 2007 »

Very very easy  Shocky.  :)

FreeBasic already has an example for Cairo Library , here it is

Code: [Select]
'' Cairo clock. Translated from the "C" example written by Writser Cleveringa

#include once "cairo/cairo.bi"
#include once "datetime.bi"

const SCR_W = 640
const SCR_H = 480

const PI = 3.14159265358979323846#

declare sub drawScreen()

'' main
screenRes SCR_W, SCR_H, 32

do
drawScreen()
sleep(1000)
loop until (len(inkey()) > 0)


'' Draws a clock on a normalized Cairo context
sub drawClock(cr as cairo_t ptr)

'' compute the angles for the indicators of our clock
dim as double minutes = Minute(Now()) * PI / 30
dim as double hours = Hour(Now()) * PI / 6
dim as double seconds = Second(Now()) * PI / 30

'' draw the entire context white.
cairo_set_source_rgba(cr, 1, 1, 1, 1)
cairo_paint(cr)

'' who doesn't want all those nice line settings :)
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)
cairo_set_line_width(cr, 0.1)

'' translate to the center of the rendering context and draw a black
'' clock outline
cairo_set_source_rgba(cr, 0, 0, 0, 1)
cairo_translate(cr, 0.5, 0.5)
cairo_arc(cr, 0, 0, 0.4, 0, PI * 2)
cairo_stroke(cr)

'' draw a white dot on the current second.
cairo_set_source_rgba(cr, 1, 1, 1, 0.6)
cairo_arc(cr, sin(seconds) * 0.4, -cos(seconds) * 0.4, 0.05, 0, PI * 2)
cairo_fill(cr)

'' draw the minutes indicator
cairo_set_source_rgba(cr, 0.2, 0.2, 1, 0.6)
cairo_move_to(cr, 0, 0)
cairo_line_to(cr, sin(minutes) * 0.4, -cos(minutes) * 0.4)
cairo_stroke(cr)

'' draw the hours indicator     
cairo_move_to(cr, 0, 0)
cairo_line_to(cr, sin(hours) * 0.2, -cos(hours) * 0.2)
cairo_stroke(cr)

end sub

'' Shows how to draw with Cairo
sub drawScreen()

screenLock

dim as cairo_surface_t ptr cairo_surface = _
    cairo_image_surface_create_for_data(screenPtr, _
CAIRO_FORMAT_ARGB32, SCR_W, _
SCR_H, SCR_W*len(integer))

'' Create a cairo drawing context, normalize it and draw a clock.
'' Delete the context afterwards.
dim as cairo_t ptr cr = cairo_create(cairo_surface)
cairo_scale(cr, SCR_W, SCR_H)
drawClock(cr)
cairo_destroy(cr)

screenUnlock

end sub

I am still tring to make a static cairo library.



Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Need good algorithm of Magnification filter
« Reply #16 on: May 17, 2007 »
Really cool dude that you're getting on with this!
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Offline Emil_halim

  • Atari ST
  • ***
  • Posts: 248
  • Karma: 21
    • View Profile
    • OgreMagic Library
Re: Need good algorithm of Magnification filter
« Reply #17 on: May 17, 2007 »

Thanks Thygrion , appreciate  your help. :)