?
Solved

Digital Image Processing

Posted on 2001-07-18
8
Medium Priority
?
461 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 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
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
Technology Partners: 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

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

777 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