Solved

Digital Image Processing

Posted on 2001-07-18
8
452 Views
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
0
Comment
Question by:Emmiediana
8 Comments
 
LVL 22

Expert Comment

by:CJ_S
Comment Utility
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...

regards,
CJ
0
 
LVL 17

Accepted Solution

by:
inthedark earned 75 total points
Comment Utility
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
DoEvents


' 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
    DoEvents
   
Next y


0
 
LVL 17

Expert Comment

by:inthedark
Comment Utility
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:

e.g.

http://www.ph.tn.tudelft.nl/Courses/FIP/noframes/fip-istogram.html

0
 
LVL 17

Expert Comment

by:inthedark
Comment Utility
But CJ_S is right that C would be better for this job.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:slider115
Comment Utility
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.

J
0
 

Author Comment

by:Emmiediana
Comment Utility
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..:)


0
 
LVL 22

Expert Comment

by:CJ_S
Comment Utility
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)

Regards,
CJ
0
 
LVL 17

Expert Comment

by:inthedark
Comment Utility
In the previous example to make the image monochrome:


red = (reg+green+blue)/3
green=red
blue=red

col = RGB(red, green, blue)

Sounds like a fun project.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now