Solved

Digital Image Processing

Posted on 2001-07-18
8
458 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 22

Expert Comment

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

regards,
CJ
0
 
LVL 17

Accepted Solution

by:
inthedark earned 75 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
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
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:

e.g.

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

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:inthedark
ID: 6293778
But CJ_S is right that C would be better for this job.
0
 
LVL 1

Expert Comment

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

J
0
 

Author Comment

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


0
 
LVL 22

Expert Comment

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

Regards,
CJ
0
 
LVL 17

Expert Comment

by:inthedark
ID: 6330759
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

738 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