Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [source code] motion blur
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tony




PostPosted: Sun Nov 09, 2003 3:51 pm   Post subject: [source code] motion blur

based on my blur filter and thx to thoughtful for the idea Very Happy

Motion Blur is used to blur images in a direction and with magnitude, creating an effect of the object moving in that direction.

code:

%a more advanced version of the Blur Filter.
%This includes the direction and magnitude of the blur
%so that motion blurs can be created

procedure Blur(direction:int, magnitude:int)
var d:array 1..maxx, 1..maxy of int %vertual image, holds pixel colors
var c:int:=255 %just a variable for color
var cr,cb,cg:array 1..magnitude of real %temporary colors
var acr,acb,acg:real %used for average color calculation

for x:1..maxx
for y:1..maxy
d(x,y):=whatdotcolor(x,y) %records pixel colors
end for
end for

for x:magnitude..maxx-magnitude
for y:magnitude..maxy-magnitude

for m:1..magnitude
RGB.GetColor(d(x+round(cosd(direction)*m),y+round(sind(direction)*m)),cr(m),cg(m),cb(m))
end for

acr:=0
for i:1..magnitude
acr+=cr(i)
end for
acr:=acr/magnitude %average color

acg:=0
for i:1..magnitude
acg+=cg(i)
end for
acg:=acg/magnitude %average color

acb:=0
for i:1..magnitude
acb+=cb(i)
end for
acb:=acb/magnitude %average color


RGB.SetColor(c,acr,acg,acb) %create the new color
Draw.Dot(x,y,c) %draw that color
end for
end for

end Blur


Not much has changed. The only difference really is that trig is used to find which points to blur together.

Direction:int is degrees at which to blur, Magnitude:int is how many pixels in that direction will be blured.

Here're some SS:
Blur(0,10)
Posted Image, might have been reduced in size. Click Image to view fullscreen.

Blur(0,10) + redraw of text
Posted Image, might have been reduced in size. Click Image to view fullscreen.

Blur(45,25) + redraw of text
Posted Image, might have been reduced in size. Click Image to view fullscreen.

Note, I've left a border around the image of "Magnitude:int" length, so that filter would not crash, trying to get the color of a pixel outside the screen



mblur3.JPG
 Description:
 Filesize:  12.92 KB
 Viewed:  7492 Time(s)

mblur3.JPG



mblur2.JPG
 Description:
 Filesize:  10.97 KB
 Viewed:  7490 Time(s)

mblur2.JPG



mblur1.JPG
 Description:
 Filesize:  10.04 KB
 Viewed:  7485 Time(s)

mblur1.JPG


Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Sun Nov 09, 2003 7:39 pm   Post subject: (No subject)

as i said nice stuff
thoughtful




PostPosted: Mon Nov 10, 2003 3:38 pm   Post subject: (No subject)

Hey tony this is jus great, i wasn't expecting an effect this great this fast. it is splendid. Smile Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: