Dark Bit Factory & Gravity

GENERAL => Challenges & Competitions => Topic started by: Shockwave on July 20, 2011

Title: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on July 20, 2011
An example of a realtime Sobel Edge Detection routine.
Also, a little pixellation effect to make it a little more interesting.

Sorry for the small screen but it's pretty intensive and requires two 3*3 masks to be applied to each pixel and calculations on the results.

Anyway, a Youtube video is coming for those who have difficulty running this.

There are a lot of selectable options you can use to see how different effects look with this filter, all totally interactive :)

Hope you enjoy it!

Btw: The binary is packed with UPX - if your AV software gives an alert, it's your AV software and not the intro!

I'll edit in the vid as soon as it's uploaded to Zootube..


Edit: [Video added]

Please note that the video is captured at 30fps - it looks better if you run the binaries..

[youtube]t-19VMItegg[/youtube]
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Kirl on July 20, 2011
Awesome demo! Lovely effects and it all runs really smooth!  :clap:

Text was a bit hard to read at times.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on July 20, 2011
Ah, cheers Kirl - I probably could have chosen a bigger font but I really love Frankie Ghost.. There's not much interesting text anyway I should make more of an effort next time! :)
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Hotshot on July 21, 2011
That is so Cool  :clap:

It run so smooth on window and full screen! :)
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on July 21, 2011
Thanks Hotshot, glad you liked it and it ran smooth for you.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Raizor on July 21, 2011
Runs super smooth for me.

Very nice Shockwave! Good work on all the different toggles too, lots to play with :)

Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: padman on July 21, 2011
Wow, this is indeed awesome stuff and just rules! (http://www.webanarchy.net/v3/images/smilies/jawdrop0.gif) Music's nice too. Well done!
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: zawran on July 21, 2011
No problems running it on my computer, and that sobel effect is really nicely done. Also cool that you allowed for some interactivity.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on July 21, 2011
Thank you very much for the kind comments!

I'm pleased that it's running full frame rate for you so far :)  Makes me think I could have maybe pushed the resolution a bit higher...
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Rbz on July 21, 2011
Very well done mate :goodpost:

Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: ferris on July 21, 2011
Hey, lots of stuff happening here, and very fast! I'm actually quite impressed with the raw speed of this.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on July 21, 2011
Thanks guys :)
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: combatking0 on July 21, 2011
It runs smooth even with my AV switched on ???

Still, I do like the range of effects, this time simultaneously. Excellent effort, and the tune is catchy.

The F-Key options are a plus too. Choosing a winner is going to be difficult again, but that's one of the things that makes these competitions worth entering.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on July 21, 2011
It runs smooth even with my AV switched on ???

I am really glad to hear that... There are over 20 calculations needed for each pixel in the Sobel area, I really did think that this was going to frame out on a lot of systems.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: combatking0 on July 22, 2011
From the looks of it, it works a lot faster than Flash.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: rain_storm on July 22, 2011
Awesome work Shocky.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: benny! on July 22, 2011
Absolutely fantastic job there. I did not expect that a complete intro is the result of this competition really. But you
make a outstanding intro there. Very well done, mate!  :clap:
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on July 22, 2011
Thanks :) I'm really glad you both liked it!
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Pixel_Outlaw on July 31, 2011

This is a very polished demo given the time that you had to work with.
I never really never cared for the Sobel filter until your demo!
Through adjusting the settings you can really see that there is not just one size fits all approach with such a filter I like that you have let us see the demo from different approaches.
I also like the pixely bottom filter it is pleasant and really makes you see how data can be crunched down with resolution. (I think it looks great)
The time spent to create different shapes and effects behind the square sobel filter is also noted, well done showcasing the effect on different subjects.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Kirl on July 31, 2011
I'm jealous of the smooth tunnel alone, the rest of the effects are just rubbing it in my nose!  ;D

[edit] That seems weird, I believe that sould be: rubbing my nose in it...   ???
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on July 31, 2011
Thanks both your comments are very kind :)

Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: jace_stknights on August 01, 2011
 :clap: Marvelous! So... demo :P
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: 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 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
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on August 03, 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.

Code: [Select]
    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.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: hellfire on August 03, 2011
Code: [Select]
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 (http://en.wikipedia.org/wiki/Sobel_operator#Formulation) is symmetric you can separate it into 2 passes, each using a 3x1 matrix:
Code: [Select]
            ( 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.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on August 04, 2011
That's a nice optimisation, thanks Hellfire it didn't occur to me to do it that way :)

K+
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Moroboshisan on August 04, 2011
 :o

lovely effect, nice feeling... love it every time i give it a run!
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: combatking0 on August 06, 2011
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.
Title: Re: [IMAGE PROCESSING] 18 Magic Digits
Post by: Shockwave on August 06, 2011
Thanks guys, you're very kind :)