PDA

View Full Version : Paint Filter Tutorial



LCS
04-03-2005, 01:37 PM
Here is a filter tutorial I wrote. A filter is an effect that is applied to an image like in a photoshop program, there are tons of effects you can do with a filter I've listed how to do a few, so you guys can discover some for your selves :) .

[Filter Tutorial]
By LCSBSSRHXXX

Hey every one I wrote this tutorial because it was pretty hard to figure out how to make filters for my paint program, I got a little help from my dad with some of the ways to process an image, and some I figured out by going into photo shop and finding the differences from the RGB values in the original picture and the return picture
and I spent a few days expermenting and writing filters from trial and error and from thinking.

Grey Scale
The average of the RGB values then the avrage of the pixel's RGB apply that value to the RGB values

Invert Colors
Subtract The RGB values from 255.
Birghten
Add to the RGB value.
Darken
Subtract to the RGB value.
Dodge
Multiply the RGB value by 2.
Burn
Divide the RGB value by 2.
Noise
Add or subtract a random number from the RGB values.

Here Are Two In Depth Tutorials For Making A Filter, With Examples

Grey Scale
grey scale is the color range from black (RGB(0,0,0)) to white (RGB(255,255,255)) if you want to convert an image
to grey scale you need to get all the RGB values equal, the method I used to convert a image to grey scale is:
[1] Get Images Pixels
[2] Set a variable to the value of the average of the pixels RGB values set a variable to it (greycolor = R + G + B / 3)
[3] Set a pixel with "greycolor" (The variable you set the average of the pixel's RGB) over the old pixel, this gets the
pixel into grey scale

example:


Dim greycolor as Integer
Private Declare Function SetPixel Lib "Gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Sub Invert()
For Y = 0 To (Picture.Height / Screen.TwipsPerPixelY)
For X = 0 To (Picture1.Width / Screen.TwipsPerPixelX)
R =Picture1.Point(X, Y) And 255
G = (Picture1.Point(X, Y) And 65280) / 256
B = (Picture1.Point(X, Y) And 16711680) / 65535
greycolor = (R + G + B) / 3
SetPixel Picture1.hdc, X, Y, RGB(greycolor, greycolor, greycolor)
Next X
Next Y
End Sub

Invert Colors
Inverting colors takes a image and turns the colors to oppisite colors, or inverted colors. To invert an image I do this:
[1] Get Images Pixels
[2] Set a pixel with RGB(255 - R, 255 - G, 255 - B)

example:

Private Declare Function SetPixel Lib "Gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Sub Invert()
For Y = 0 To (PicBox.Height / Screen.TwipsPerPixelY)
For X = 0 To (Picture1.Width / Screen.TwipsPerPixelX)
R =Picture1.Point(X, Y) And 255
G = (Picture1.Point(X, Y) And 65280) / 256
B = (Picture1.Point(X, Y) And 16711680) / 65535
greycolor = (R + G + B) / 3
SetPixel Picture1.hdc, X, Y, RGB(255 - R, 255 - G, 255 - B)
Next X
Next Y
End Sub

Uniquely_Defined
04-03-2005, 02:07 PM
Nice job on the tutorial. Thanks for writing it, gave me a little insight to filters.

Noober
04-03-2005, 03:46 PM
Well if you're using Photoshop you can just do image>mode>grayscale, and to invert it just press ctrl+i.

LCS
04-03-2005, 03:51 PM
This tutorial explains how to make your own greyscale and other effects, basically the purpose of this tutorial is to explain how to go about making your own photoshop effects.

punture
04-03-2005, 05:53 PM
Can I just leech some tutorials off of some siteS???

Of course I'll give credit..

FireXtol
04-03-2005, 06:11 PM
Those aren't filters. *shakes head*

All good filters use matrices... And a better filter uses a large matrix!

There's even a greyscale and inversion matrix.

And I'm pretty sure L=0.3*RED+0.59*GREEN+0.11*Blue, is faster at color to greyscale conversion than (r+g+b)/3. Which you could then bitshift and logically AND together to form a 24 bit greyscale image...:

L=0.3*RED+0.59*GREEN+0.11*Blue
c= L * 256 'bitshift
c= (c and L) * 256 ' GR
c= c and L 'BGR