You are on page 1of 11

This coursework has been assigned for me.

However, Im at beginner level for programming


using VB 6. Please program the codes using crude / simple algorithm to represent my
capability at this level. Please have a look at all my codes which I have attempted so you
would be able to understand my competency.
Please READ carefully my instructions, do contact me if you are in doubt.
This what I have done so far (Image 640 x 480)

Figure 1
Option Explicit
Private Sub btnGreyScale_Click() ****** Method for Greyscale
ReDim picArray(Picture1.ScaleWidth, Picture1.ScaleHeight) As Long
Dim row As Integer
Dim col As Integer
Dim picPixel As Byte
For row = 0 To Picture1.ScaleWidth - 1
For col = 0 To Picture1.ScaleHeight - 1
picArray(row, col) = Picture1.Point(row, col)
'*** get average of RGB values ****
picPixel = (((&HFF And picArray(row, col)) + _
((&HFF00FF00 And picArray(row, col)) \ &H100) + ((&HFF0000 And picArray(row, col)) \
&H10000)) \ 3)
1

Picture1.PSet (row, col), RGB(picPixel, picPixel, picPixel)


Next
Next
MsgBox " Finished ", vbOKOnly
End Sub

Private Sub btnThreshold_Click()


ReDim picArray(Picture1.ScaleWidth, Picture1.ScaleHeight) As Long
Dim row As Integer
Dim col As Integer
Dim picPixel As Long
For row = 0 To Picture1.ScaleWidth - 1
For col = 0 To Picture1.ScaleHeight - 1
picArray(row, col) = Picture1.Point(row, col)
'*** get average of RGB values ****
picPixel = (((&HFF And picArray(row, col)) + _
((&HFF00FF00 And picArray(row, col)) \ &H100) + ((&HFF0000 And picArray(row, col)) \
&H10000)) \ 3)
If picPixel > txtThreshold.Text Then picPixel = 255 Else picPixel = 0 ' this line to threshold it
Picture1.PSet (row, col), RGB(picPixel, picPixel, picPixel)
Next
Next
End Sub
Private Sub btnAquire_Click() ' Aquire button pressed
Dim myImage As String
Picture1.Picture = LoadPicture("U:\Mechatronics B\Threshold_Manual\platform_image.bmp")
End Sub

Task 1: Median Filter from RGB and Greyscale Image


a)
b)
c)
d)
e)
f)
g)

Create a NEW project as shown below with 2 main buttons.


You are required to use Median Filter to filter the image from noise
Use private function or subroutine
Use the same notation as the example I have given you above.
Please use simple/ crude algorithm, easy for beginner to understand
Please comment on each line of code
Repeat again using Median Filter for greyscale image

Figure 2

Task 2: Greyscale
a) I have done it. The code was given on page 2.
b) I have created 2 main buttons

Figure 3

Task 3: Automatic Thresholding


a) Automatic thresholding is to convert greyscale image to binary image 0 and 1 black and
white.
b) Create a NEW project as shown below with 4 main buttons.
c) Two methods are required: (1) Threshold the image into black and white using median
threshold, (2) finding the threshold value by using histogram, return the threshold value
in a textbox. I forgot to include in the diagram below.
d) Please refer to page 1 for the code of greyscale.
e) Please use simple/ crude algorithm, easy for beginner to understand
f) Please comment on each line of code

Figure 4

Task 3: Sobel Edge Detection


a)
b)
c)
d)

Create a NEW project as shown below with 4 main buttons.


Use Sobel Convolution Masks X and Y for edge detection
Please use simple/ crude algorithm, easy for beginner to understand
Please comment on each line of code
Example for Sobel Operators
X-gradient
-1
0
1
-2
0
2
-1
0
1

1
0
-1

Y-gradient
2
1
0
0
-2
-1

Figure 5

Task 3: Hough Transform


a)
b)
c)
d)
e)

Create a NEW project as shown below


Use Hough Transform to find accurate centre location for circular objects
The row and column return the values of each objects from reference point.
Please use simple/ crude algorithm, easy for beginner to understand
Please comment on each line of code

A Hough-based procedure for locating circular objects


a) Locate edges within the image
b) Link broken edges
c) Thin thick edges
d) For every edge pixel, find a candidate centre point
e) Locate all clusters of candidate centres
f) Average each cluster to find accurate centre location

Figure 6

Task 4: Using VB 6 to determine the dribbling path as shown in


Figure 7
a) I dont have any idea for this task
b) The code should be able to determine the path that should be taken without colliding
with opposition players to the goal area.

Figure 7

Task 5: Angle of shooting


a) The VB software must decide whether a shot is possible or not, and this must be
announced on the VB interface.
b) The angle of shooting should be displayed in text box as shown in Figure 10.

Figure 8

Figure 9

10

Figure 10

At the end, I will expect to see the projects as follows:


a)
b)
c)
d)
e)
f)
g)
h)

Median filter for colour image (see Figure 2)


Separate project for Median filter for greyscale image (see Figure 2)
Automatic thresholding using median value of greyscale (see Figure 4)
Separate project for Automatic thresholding using histogram value of greyscale (see
Figure 4)
Sobel edge detection method (see Figure 5)
Hough Transform which can determine the centre location of circular objects (see
Figure 6)
VB program for dribbling path
VB program for Angle of shooting

11

You might also like