# Image graphics using Pset Problem

Page 1 of 1

## 1 Replies - 1696 Views - Last Post: 08 March 2013 - 10:51 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=314758&amp;s=adf254bd5d6107869f8ec18c7908f5e0&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ali99

Reputation: 0
• Posts: 16
• Joined: 20-February 12

# Image graphics using Pset Problem

Posted 08 March 2013 - 09:15 AM

Hi,
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

Is This A Good Question/Topic? 0

## Replies To: Image graphics using Pset Problem

### #2 BobRodes

• Lovable Curmudgeon

Reputation: 590
• Posts: 3,041
• Joined: 19-May 09

## Re: Image graphics using Pset Problem

Posted 08 March 2013 - 10:51 PM

Read up on "laplacian operator image sharpening".

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }