Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Brainnet 1 - A Neural Netwok Project - With Illustration And Code - Learn Neural Network Programming Step By Step And Develop a Simple Handwriting Detection System

, 4 Apr 2007
This article is expected to (1) Demonstrate some practical uses neural network programming (2) Give you a fair idea regarding neurons, neural networks and their applications (3) Introduce BrainNet library - an open source Artificial Neural Network library I developed - mainly using the MS.NET
neuralnetwork_source.zip
BrainNetIntro
BrainNetLibrary
BrainNet.NeuralFramework.dll
Documentation.chm
NeuralGate
bin
BrainNet.NeuralFramework.dll
NeuralGate.exe
NeuralGate.vbproj.user
PatternDetector
bin
BrainNet.NeuralFramework.dll
PatternDetector.exe
TestImages
a1.bmp
b1.bmp
b2.bmp
c1.bmp
c2.bmp
D.bmp
D1.bmp
D2.bmp
E1.bmp
E2.bmp
PatternDetector.vbproj.user
neuralnetwork_src.zip
Public Class PatternDraw
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents picCanvas As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.picCanvas = New System.Windows.Forms.PictureBox()
        Me.SuspendLayout()
        '
        'picCanvas
        '
        Me.picCanvas.BackColor = System.Drawing.Color.White
        Me.picCanvas.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.picCanvas.Location = New System.Drawing.Point(9, 8)
        Me.picCanvas.Name = "picCanvas"
        Me.picCanvas.Size = New System.Drawing.Size(160, 160)
        Me.picCanvas.TabIndex = 0
        Me.picCanvas.TabStop = False
        '
        'PatternDraw
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(180, 210)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.picCanvas})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.Name = "PatternDraw"
        Me.Text = "Draw Pattern"
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private m_Drawing As Boolean
    Private m_LastX As Integer
    Private m_LastY As Integer

    Private m_Bitmap As Bitmap
    Private m_Graphics As Graphics

    ' Allocate the first Bitmap.
    Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AllocateBitmap()
    End Sub

    ' Make a new Bitmap to draw on.
    Private Sub Form_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        AllocateBitmap()
    End Sub

    ' Make a new Bitmap to draw on.
    Private Sub AllocateBitmap()
        ' Make the PictureBox fill the form.


        ' Make a new Bitmap.
        m_Bitmap = New Bitmap(picCanvas.Width, picCanvas.Height)

        ' Make a Graphics object to draw on the Bitmap.
        m_Graphics = Graphics.FromImage(m_Bitmap)

        ' Make the PictureBox show the empty Bitmap.
        picCanvas.Image = m_Bitmap
    End Sub

    ' Start scribbling.
    Private Sub picCanvas_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picCanvas.MouseDown
        m_Drawing = True
        m_LastX = e.X
        m_LastY = e.Y
    End Sub

    ' Continue scribbling.
    Private Sub picCanvas_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picCanvas.MouseMove
        If m_Drawing Then
            ' Draw the new line.



            If e.Button = MouseButtons.Left Then
                m_Graphics.FillEllipse(New SolidBrush(Color.Black), e.X - 15, e.Y - 15, 30, 30)
            Else
                m_Graphics.FillEllipse(New SolidBrush(Color.White), e.X - 15, e.Y - 15, 30, 30)
            End If

            ' Display the result.
            picCanvas.Image = m_Bitmap

            ' Save the latest point.
            m_LastX = e.X
            m_LastY = e.Y
        End If
    End Sub

    ' Stop scribbling.
    Private Sub picCanvas_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picCanvas.MouseUp
        m_Drawing = False
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author


| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.1411023.1 | Last Updated 4 Apr 2007
Article Copyright 2006 by Anoop Madhusudanan
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid