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

Designing And Implementing A Neural Network Library For Handwriting Detection, Image Analysis etc.- The BrainNet Library - Full Code, Simplified Theory, Full Illustration, And Examples

, 21 Oct 2009
This article will explain the actual concepts and implementation of Backward Propagation Neural Networks very easily - see project code and samples, like a simple pattern detector, a hand writing detection pad, an xml based neural network processing language etc in the source zip.
brainnet_src.zip
BrainNetIntro
NeuralGate
NeuralGate.vbproj.user
PatternDetector
PatternDetector.vbproj.user
TestImages
a1.bmp
b1.bmp
b2.bmp
c1.bmp
c2.bmp
D.bmp
D1.bmp
D2.bmp
E1.bmp
E2.bmp
Thumbs.db
Framework
BrainNet.suo
NetworkDataModel
Network.xsx
NeuralXML.xsx
NetworkIO.xsx
NeuralFramework.vbproj.user
nxml
nxml.vbproj.user
BrainNet.suo
Doc
Documentation.chm
Samples
HandWriting
HandWriting.suo
HandWriting.vbproj.user
'------------------------------------------------------------------
' License Notice:
'------------------------------------------------------------------
' All Rights Reserved - Anoop Madhusudanan, 
' Mail: amazedsaint@gmail.com
' Website: http://amazedsaint.blogspot.com

' See my articles about BrainNet at 
' http://amazedsaint-articles.blogspot.com for details
'
' You can use this code (or part of it), for non 
' commercial and academic uses, as long as 
'   - You are keeping this notice along with it
'   - You are not making any profit out of this
'------------------------------------------------------------------

'''<summary> The class provides some basic image processing methods
'''and conversions required for neural network image processing  </summary>

Public Class PatternProcessingHelper
    '''<summary> Convert a binary string to an arraylist </summary>
    Public Function ArrayListFromPattern(ByVal pattern As String) As ArrayList
        Dim arr As ArrayList = New ArrayList()
        Dim counter As Long
        For counter = 0 To pattern.Length - 1
            arr.Add(pattern.Chars(counter).ToString)
        Next
        Return arr

    End Function

    '''<summary> Convert an arraylist by rounding each value to a pattern of 0s and 1s </summary>
    Public Function PatternFromArraylist(ByVal arr As ArrayList) As String
        Dim no As Long
        Dim str As String = ""

        For no = 0 To arr.Count - 1
            str = str & Math.Round(arr(no))

        Next

        Return str
    End Function


    '''<summary> Convert an arraylist by rounding each value to a pattern of 0s and 1s </summary>
    Public Function NumberFromArraylist(ByVal arr As ArrayList) As Long
        Return NumberFromPattern(PatternFromArraylist(arr))

    End Function


    '''<summary> Convert an arraylist to a character </summary>
    Public Function CharFromArraylist(ByVal arr As ArrayList) As String
        Return Chr(NumberFromPattern(PatternFromArraylist(arr)))
    End Function


    '''<summary>Arraylist to a character </summary>
    Public Function ArrayListFromChar(ByVal ch As String) As ArrayList
        Return ArrayListFromNumber(Asc(ch), 8)
    End Function


    '''<summary> Convert a binary string to an arraylist </summary>
    Public Function ArrayListFromNumber(ByVal value As Long, ByVal lengthOfList As Long) As ArrayList
        Dim pattern As String = PatternFromNumber(value, lengthOfList)

        Dim arr As ArrayList = New ArrayList()
        Dim counter As Long
        For counter = 0 To pattern.Length - 1
            arr.Add(pattern.Chars(counter).ToString)
        Next
        Return arr

    End Function

    '''<summary> Convert a binary string to decimal value </summary>
    Public Function NumberFromPattern(ByVal pattern As String) As Long

        Dim number As Long = 0

        Dim i, bit
        For i = 0 To pattern.Length - 1
            If pattern.Chars(pattern.Length - 1 - i) = "1" Then
                bit = 1
            Else
                bit = 0
            End If

            number = number + ((2 ^ i) * bit)

        Next

        Return number

    End Function


    '''<summary> Get an string pattern of 0s and 1s corresponding to a value. Eg. 1 
    '''will be converted to 01, 2 to 10 and so on </summary>

    Public Function PatternFromNumber(ByVal number As Integer, ByVal lengthOfPattern As Long) As String

        Dim pattern As String = ""

        Dim max As Integer = 0

        Dim i

        '''Find the maximum number of bits that can accomodate the value
        max = lengthOfPattern

        For i = 0 To max - 1
            If ((2 ^ i) And number) = (2 ^ i) Then
                pattern = "1" & pattern
            Else
                pattern = "0" & pattern
            End If

        Next

        Return pattern

    End Function
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 21 Oct 2009
Article Copyright 2006 by Anoop Madhusudanan
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid