Author Topic: How to code a PolarFilter algo like Pho7o$hop?  (Read 4570 times)

0 Members and 1 Guest are viewing this topic.

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
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:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: How to code a PolarFilter algo like Pho7o$hop?
« Reply #1 on: June 01, 2007 »
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:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: How to code a PolarFilter algo like Pho7o$hop?
« Reply #2 on: June 07, 2007 »
theres some info located on paule bourkes pages.. i suggest you take a look here: http://local.wasp.uwa.edu.au/~pbourke/texture_colour/polargrid/index.html
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: How to code a PolarFilter algo like Pho7o$hop?
« Reply #4 on: June 10, 2007 »
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:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: How to code a PolarFilter algo like Pho7o$hop?
« Reply #5 on: June 10, 2007 »
Attached Blitz code can do strudel.

Jim
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: How to code a PolarFilter algo like Pho7o$hop?
« Reply #6 on: June 10, 2007 »
@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: