Digital Image Processing

Posted on 2001-07-18
Medium Priority
Last Modified: 2012-06-27
How to write programs in Visual Basic to do the following intensity transformations:
1) Image negatives
2)Contrast stretching
3)Gray level slicing
4)Bit plane slicing
5)Histogram equalization
6)Low pass spatial filtering using 3*3 mask
Question by:Emmiediana
LVL 22

Expert Comment

ID: 6293454
You will need to use the API. You will need to write code that can examine each and every single pixel, and the pixels around it. I have done quite some digital image processing in C++, and can show you a simple sample in C++. (The functions are mainly the same as in VB, you will just need to add the appropriate API functions).

If you want I can send you an email with the sample...the code is in C++ though which is better for digital image processing in my opinion. I have the sample at home...

LVL 17

Accepted Solution

inthedark earned 225 total points
ID: 6293746
Images in VB a quite simple.  The hard bit is knowing what to do to each pixel to get the desired effect.

All image functions are a variation of the following VB code:

Add a pixture box & a command button to a form.

Edit the properties of the picture box and load an image into the picture property.

Paste the following code.
And run.

Sub Command1_Click

Dim x As Long
Dim y As Long
Dim h As Long
Dim w As Long
Dim col As Long

Dim red As Long
Dim green As Long
Dim blue As Long
Dim P As PictureBox

' Make sure the picture and form have a scalemode of pixels.

Me.ScaleMode = 3
Set P = Picture1
P.BorderStyle = 0
P.ScaleMode = 3 ' pixel

' w & h = no. of pixels to process
h = P.Height
w = P.Width

' loop through each pixel
For y = 0 To h
    For x = 0 To w

        col = P.Point(x, y) ' get the current pixel colour

        ' break down into parts
        ' you could speed this up using "And"
        red = Int(col / 65536)
        green = Int(col / 256) - red * 256
        blue = col as 255
        ' make a colour negative
        red = 255 - red
        green = 255 - green
        blue = 255 - blue
        col = RGB(red, green, blue)

        P.PSet (x, y), col ' paint the new colour back ontop of the old pixel

    Next x
Next y

LVL 17

Expert Comment

ID: 6293774
All you need now are the algorithms for:

2)Contrast stretching
3)Gray level slicing
4)Bit plane slicing
5)Histogram equalization
6)Low pass spatial filtering using 3*3 mask

The net is probably the best source for a solution to this:



What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 17

Expert Comment

ID: 6293778
But CJ_S is right that C would be better for this job.

Expert Comment

ID: 6294498
Check out this book:

Visual Basic Graphics Programming (2nd Ed), Hands-On Applications and Advanced Color Development, Rod Stevens

It has tons of algorithms (easy to advanced), including most of the one's you are looking for.


Author Comment

ID: 6304203
To all that have posted their comments regarding my question on digital image processing..thanx a lot!!
Anyway..i still need your help....:)

To CJ,
Could you please send me those codes in C++?? :)
I'm really looking forward to view the codes and study them...

To inthedark,
Thanx for the VB codes...
I've tried it out ...and now i got some ideas to do the other intensity transformations...
(Anyway,frankly speaking...i still find it difficult..
anyone can help me??? :) )
btw...thanx for the url address....

To slider 115,
thanx for suggesting me the book..:)

LVL 22

Expert Comment

ID: 6329596
I tried sending them to you yesterday at work. But I got it returned... so I have send another email saying that your mailbox was probably full. I don't know whether you have replied yet, but i will see that on monday.... or else, give me your email addy again (which can take 1.2 MB)

LVL 17

Expert Comment

ID: 6330759
In the previous example to make the image monochrome:

red = (reg+green+blue)/3

col = RGB(red, green, blue)

Sounds like a fun project.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question