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:
opendio.ShowDialog() 'open file Label1.Text = opendio.FileName 'print path on label Picture.Image = Image.FromFile(opendio.FileName) 'show image in box Dim photo As New Bitmap(opendio.FileName) 'save image as varable Dim count As Integer ' number of white pixels Dim y As Integer 'y pixel Dim x As Integer 'x pixel Dim photomaxX As Integer = photo.Size.Width 'how many pixels on X axes Dim photomaxY As Integer = photo.Size.Height 'how many pixels on Y axes For y = 0 To photomaxY - 1 'go though the y axis For x = 0 To photomaxX - 1 'go though the x axis If photo.GetPixel(x, y).Equals(Color.White) Then 'if the pixel color is white count = count + 1 'add one End If Next Next 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




Reply With Quote