• Welcome to Dark Bit Factory & Gravity.
 

How to code a PolarFilter algo like Pho7o$hop?

Started by va!n, May 30, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

va!n

I would like to see an easy to understand and easy portable basic source, of the "Polar Filter" algo (rectangular -> polar)... i think its a small modification of a twirl algo... however, i dont really know how to code both effects... if someone can help and show a basic source, it would be great!

so thanks in advance!
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Tetra

I've had a go at trying to figure this one out, but i've hit a snag. The way I see it is that there are two coordinate sets.
The first is texture space and the second is the Polar space. I have no problems converting texture space to Polar space, but this is not the way to do it. It fragmented and incorrect. The way to do it is to convert Polar space into Texture space, this way you dont get any fragmentation. Unfortunately I lack the mathematical ability to figure out how to reverse the process so I can convert Polar to Texture space.

Heres how to convert Texture to Polar space: -

Quote
Function Polar()
   
   Local xScale# = 0.675
   Local yScale# = 0.5
   Local cx#
   
   
   ; Texture Image size
   Local iWidth = ImageWidth( TextureImage )
   Local iHeight = ImageHeight( TextureImage )

   ; Texture Image size halved
   Local half_iWidth = Floor( iWidth / 2 )
   Local half_iHeight = Floor( iHeight / 2 )      
   
   
      For y = 0 To iHeight-1
         For x = 0 To iWidth-1
            
            ; x reprisents the rotation angle from 0 -> 360
            ; convert the x position into an angle
            cx# = ( x - half_iWidth ) * ( 360.0 / Float(iWidth) )
            
            ; y is effectively the diameter
            ; the coords can also be scaled
            ; Finally move to the center of the Polar space
            nx = ( xScale# * Sin( cx# ) * y ) + half_iWidth
            ny = ( yScale# * Cos( cx# ) * y ) + half_iHeight
      
            ; ensure the pixel falls within the texture range
            If ( nx < 0 ) Then nx = 0
            If ( nx >= iWidth ) Then nx = iWidth - 1
      
            If ( ny < 0 ) Then ny = 0
            If ( ny >= iHeight ) Then ny = iHeight - 1               

            
            ; read the texture pixel color
            srcPixel = ReadPixel( x,y, TextureImage )
            
            ; write the pixel in Polar Space
            WritePixel( nx,ny, srcPixel, PolarImage )

         
         Next
      Next
            
End Function

But can anyone else help with converting Polar to Texture space, i.e. Reversing the above equation?
Challenge Trophies Won:

mind

Challenge Trophies Won:

taj

Challenge Trophies Won:

va!n

sorry for the delay..

@Tetra:
thanks for sharing the code... i have converted the source and its not what i am looking for... (or i did somewhere a mistake ^^)

@all:
ofcourse thanks for for feedbacks too... i will show you a screenshot from PShop what algos i am interested in ^^





:cheers:
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Jim

Attached Blitz code can do strudel.

Jim
Challenge Trophies Won:

va!n

@jim:
cool. thanks... i will take a look to it  :goodpost:
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won: