Jump to content

Object Detection using Get/Set Pixels

- - - - -

  • Please log in to reply
No replies to this topic

#1
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
Hi guys,

I've been looking into motion detection and object detection today and have came up with this code :
Public Function translateImage(ByVal starting_image As Bitmap)
        Dim wid As Integer = Math.Min(PictureBox1.Width, PictureBox3.Width)
        Dim hgt As Integer = Math.Min(PictureBox1.Height, PictureBox3.Height)
        Dim first_image As Bitmap
        first_image = starting_image
        Dim finished_image As Bitmap
        finished_image = starting_image
        Dim pic_color As Bitmap
        pic_color = PictureBox3.Image
        Dim xcord As Integer = 1
        Dim ycord As Integer = 1
        For x As Integer = 0 To wid - 1
            For y As Integer = 0 To hgt - 1
                If finished_image.GetPixel(x, y).Equals(pic_color.GetPixel(x, y)) Then
                    finished_image.SetPixel(x, y, Color.Pink)
                Else
                End If

            Next y
        Next x

        PictureBox2.Image = finished_image


        Return 0
    End Function


What I'm trying to do is look for Black areas on the first image, then apply a pink color to the black areas on the finished image.

However, what I'm getting is a small block of pink on the image (Around 1/4 of the size). I'm not sure what I've done wrong as I've gone through the code a lot of times and just can't find anything wrong with it.

Any code gurus out there think they can help me?

~ Alex




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users