• Welcome to Dark Bit Factory & Gravity.
 

[IMAGE PROCESSING] 18 Magic Digits

Started by Shockwave, July 20, 2011

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Shockwave

Thanks both your comments are very kind :)

Shockwave ^ Codigos
Challenge Trophies Won:

jace_stknights

Challenge Trophies Won:

SERGIO_ManOwaR_

Its a cool demo, looks great. I only have a dissapoint wich is based in the limitated effects that reduces to a window filtering real-time. I guess that all those animated graphics may create some spectation and after all i was really specting to find more effects. Thats the worst i have to say, anything else is great. I have no problem to watch it speedy, no slow-downs in my computer so it moves perfectly smooth and everything is cool. Remember me old paradox demos in playstation games, even the music. Nice to see. Good work

Shockwave

Quote from: SERGIO_ManOwaR_ on August 02, 2011
Its a cool demo, looks great. I only have a dissapoint wich is based in the limitated effects that reduces to a window filtering real-time.

I decided on the Sobel filter which needs to do over 20 calculations per pixel so I had some choices to make about it. 

I could have applied the filter to a static image and not cared about the resolution but this is running over some real time effects so I had to either do it within something more powerful than Freebasic, like shader language (which I don't know), or sacrifice the framerate to have a higher resolution, or reach a compromise which I did.

I decided that it would be nice to have a window where you could see the sobel filter affecting a real time image so you could see it acting on something live and moving.

If you consider that my code is actually doing the following loop on the sobel part of the screen, maybe you can appreciate better why the window is small.


    DIM AS DOUBLE INOUT
    INOUT = 120
    PP2=@RENDER_BUFFER((xres*70))   
            FOR Y = 70 TO YRES-70   
                PP3=@SCREEN_BUFFER(X+((Y-1)*XRES))
                FOR X = 0 TO XRES-1
                    IF ( Y < 1 ) OR (Y >= YRES-1) OR (X < INOUT) OR (X >XRES-INOUT) THEN                       
                        *PP2 =  * PP3
                    ELSE                       
                        SUMX = 0
                        SUMY = 0
                        PP=@SCREEN_BUFFER(X+((Y-1)*XRES))
                        FOR I= -1 TO 1                                                       
                            PP-=1
                            FOR J=-1 TO 1                                                               
                                CURP = *PP+J
                                    SUMX += CURP * GX(J+1,I+1)
                                    SUMY += CURP * GY(J+1,I+1)
                                PP+=1
                            NEXT
                            PP+=XRES
                        NEXT                       
                        SUM = ABS((SUMX)+ABS(SUMY)) * SOBELSENSE
                        *PP2 = PALETE (SUM)
                    END IF                                       
                    PP2+=1         
                    PP3+=1
                NEXT
            NEXT


Your point of having a limited number of effects is a fair one though, I used up all the time I could by trying to add a variety of effects so you could see the soblel working on them instead of perhaps having one effect and more filters.
Shockwave ^ Codigos
Challenge Trophies Won:

hellfire

#24
Quote from: Shockwave on August 03, 2011
FOR I= -1 TO 1                                                       
  PP-=1
  FOR J=-1 TO 1                                                               
    CURP = *PP+J
    SUMX += CURP * GX(J+1,I+1)
    SUMY += CURP * GY(J+1,I+1)
    PP+=1
  NEXT
  PP+=XRES
NEXT
Since the 3x3 sobel matrix is symmetric you can separate it into 2 passes, each using a 3x1 matrix:

            ( 1 )   (-1 0 1 )
(1,0,-1) * ( 2 ) = (-2 0 2 )
            ( 1 )   (-1 0 1 )

This way you just need six adds instead of 9 multiply-add.
Challenge Trophies Won:

Shockwave

That's a nice optimisation, thanks Hellfire it didn't occur to me to do it that way :)

K+
Shockwave ^ Codigos
Challenge Trophies Won:

Moroboshisan

 :o

lovely effect, nice feeling... love it every time i give it a run!

combatking0

I might have said this before, but I'll say it again - 5 effects running simultaneously, this smoothly - words cannot describe how excellently brilliant this is.
You are our 9001st visitor.
Challenge Trophies Won:

Shockwave

Thanks guys, you're very kind :)
Shockwave ^ Codigos
Challenge Trophies Won: