Results 1 to 16 of 16

Thread: Colors [Solved]

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    Resolved Colors [Solved]

    Hello, a friend and I are doing a science project it is on the percentage of bacteria growing we grew them in a dish and took a photo of them. We then made the photo so that it is a monochrome photo with black as no bacteria and white as bacteria.

    It is very difficult to find a accrete percentage the manual way so we want to use a computer to help us. We decided to use the pixels of the photo.

    In visual basic I wrote the fallowing program

    VB Code:
    1. opendio.ShowDialog() 'open file
    2.         Label1.Text = opendio.FileName 'print path on label
    3.         Picture.Image = Image.FromFile(opendio.FileName) 'show image in box
    4.         Dim photo As New Bitmap(opendio.FileName) 'save image as varable
    5.  
    6.         Dim count As Integer ' number of white pixels
    7.         Dim y As Integer 'y pixel
    8.         Dim x As Integer 'x pixel
    9.         Dim photomaxX As Integer = photo.Size.Width 'how many pixels on X axes
    10.         Dim photomaxY As Integer = photo.Size.Height 'how many pixels on Y axes
    11.         For y = 0 To photomaxY - 1 'go though the y axis
    12.             For x = 0 To photomaxX - 1 'go though the x axis
    13.                 If photo.GetPixel(x, y).Equals(Color.White) Then 'if the pixel color is white
    14.                     count = count + 1 'add one
    15.                 End If
    16.             Next
    17.         Next
    18.  
    19.         MsgBox(count / (photomaxX * photomaxY)) ' show percentage in decmal form

    the issue is it always comes up as 0% no matter what picture it is. they are monocrome bitmaps that we are using
    Last edited by tonyrueb; Dec 18th, 2006 at 12:05 AM. Reason: Solved -- Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width