I'm working on creating a program that will handle images pixel by pixel.
Basically what this program does is it adds filters to an image of the user's choice,
now i know there are more than one method of doing this but i'm using visual basic's Pset , I know it's very slow but since I'm working on a relatively small image (picturebox) and i'm using only one loop it shouldn't take more than a 5 seconds besides I like this method because it's simple and easy to understand since the people who are going to read my code ..um.. let's say aren't very good with visual basic anyway I'm probably boring you with all the details so let's get to business:
First things first the program is going to read all the pixels from the first picturebox(picturebox1 ) using a loop that looks like this:
Dim x, y As Integer For x = 1 To Picture1.ScaleWidth For y = 1 To Picture1.ScaleHeight Pixels(x, y) = Picture1.Point(x, y) Next y Next x
now of course I'm going to use only one loop but your sake i'm doing this since my code is quite messy
and then after editing the pixels we should put them in the new picturebox(Picturebox2)
Dim x, y As Integer For x = 1 To Picture1.ScaleWidth For y = 1 To Picture1.ScaleHeight Picture2.PSet (x, y), Pixels(x, y) Next y Next x
Alright now we get to the dirty part
coming up with algorithm for the filters
so i figured out few of them
here is one for making grayscale
Pixels(x, y) = Picture1.Point(x, y) bytred = Pixels(x, y) And &HFF bytgreen = ((Pixels(x, y) And &HFF00) / &H100) Mod &H100 bytblue = ((Pixels(x, y) And &HFF0000) / &H10000) Mod &H100 bytAverage = (bytred + bytgreen + bytblue) / 3 Pixels(x, y) = RGB(bytAverage, bytAverage, bytAverage)
and here is one for making a blur
bytred = Abs((Pixels(x + 1, y) And &HFF) + (Pixels(x, y) And &HFF) + (Pixels(x + 2, y) And &HFF) + (Pixels(x + 3, y) And &HFF) + (Pixels(x + 4, y) And &HFF) + (Pixels(x + 5, y) And &HFF)) / 6 bytgreen = Abs(((Pixels(x + 1, y) And &HFF00) / &H100) Mod &H100 + ((Pixels(x, y) And &HFF00) / &H100) Mod &H100 + ((Pixels(x + 2, y) And &HFF00) / &H100) Mod &H100 + ((Pixels(x + 3, y) And &HFF00) / &H100) Mod &H100 + ((Pixels(x + 4, y) And &HFF00) / &H100) Mod &H100 + ((Pixels(x + 5, y) And &HFF00) / &H100) Mod &H100) / 6 bytblue = Abs(((Pixels(x + 1, y) And &HFF0000) / &H10000) Mod &H100 + ((Pixels(x, y) And &HFF0000) / &H10000) Mod &H100 + ((Pixels(x + 2, y) And &HFF0000) / &H10000) Mod &H100 + ((Pixels(x + 3, y) And &HFF0000) / &H10000) Mod &H100 + ((Pixels(x + 4, y) And &HFF0000) / &H10000) Mod &H100 + ((Pixels(x + 5, y) And &HFF0000) / &H10000) Mod &H100) / 6 Pixels(x, y) = RGB(bytred, bytgreen, bytblue)
So here comes up my problem i've been banging my head against the wall and searching on the internet for an algorithm to sharpen an image
and how to make more filters (bluish , yellowish , reddish ) ? :|
any help would be greatly appreciated
thanks

New Topic/Question
Reply



MultiQuote



|