Aide sur un code picturebox
Bonsoir et merci pour vos réponses et votre temps accordé
J'ai dans le code suivant une action qui me compte les pixels noir d'une image sur toute la largeur par colonne (départ hauteur+ compteur) ; ce que je voudrais aussi c'est pouvoir coder le nombre ligne noire de chaque colonne.
Voici mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
Try
Dim pc As New System.IO.StreamWriter("C:/count/pixelcompter.txt", False)
pc.WriteLine("Begin Count:")
pc.WriteLine()
pc.Close()
Dim img As Bitmap = New Bitmap(PictureBox1.Image)
Dim c As Color
For i = 0 To img.Width - 1
Dim toppix As Integer = 0
Dim pixlength As Integer = 0
Dim j As Integer
For j = 0 To img.Height - 1
c = img.GetPixel(i, j)
Dim r As Integer = 0
r = Convert.ToInt16(c.R)
Dim g As Integer = 0
g = Convert.ToInt16(c.G)
Dim b As Integer = 0
b = Convert.ToInt16(c.B)
Dim ans As Integer = ((r + (g + b)) / 3)
If (ans > 128) Then
r = 255
g = 255
b = 255
Else
r = 0
g = 0
b = 0
End If
Dim total As Integer = r + g + b
If toppix = 0 Then
If total < 765 Then
toppix = j
pixlength = 1
End If
Else
If total < 765 Then
pixlength += 1
Else
Dim pcr As New System.IO.StreamWriter("C:/count/pixelcompter.txt", True)
pcr.WriteLine(" " & i & " " & toppix & " " & pixlength)
pcr.WriteLine()
pcr.Close()
toppix = 0
pixlength = 0
End If
End If
Next
Next
Dim pce As New System.IO.StreamWriter("C:/count/pixelcompter.txt", True)
pce.WriteLine(":End Count")
pce.WriteLine()
pce.Close()
MessageBox.Show("Operation réussi")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try |
La finalité de mon projet est d'automatiser ce tutorial :
http://www.faitmain-faitcoeur.fr/en-...plie-ecriture/
Je vous remerci beaucoup