zoukankan      html  css  js  c++  java
  • BitArray

    http://www.cnblogs.com/lanse777/archive/2007/04/01/695801.html

    关于OCR矩阵采用 海明距离 检验相似度的算法实现
    将 0 1 2 3 4 5 6 7 8 9 改为直接序列化
    为 二进制 而不是 字符串然后求的时候 根据 矩形 算出长度
    根据长度
    构造一个 二进制数组
    将数组根据 RGB 赋值 0 1
    这样就有 两个 二进制 数组了
    构造两个 BitArray  求 海明距离
    然后 海明距离 跟阀值相比 计算相似度
    http://www.cnblogs.com/i80386/archive/2012/02/20/2359493.html


    using System;
    using System.Collections;
    public class SamplesBitArray  {
    
       public static void Main()  {
    
          // Creates and initializes two BitArrays of the same size.
          BitArray myBA1 = new BitArray( 4 );
          BitArray myBA2 = new BitArray( 4 );
          myBA1[0] = myBA1[1] = false;
          myBA1[2] = myBA1[3] = true;
          myBA2[0] = myBA2[2] = false;
          myBA2[1] = myBA2[3] = true;
    
          // Performs a bitwise XOR operation between BitArray instances of the same size.
          Console.WriteLine( "Initial values" );
          Console.Write( "myBA1:" );
          PrintValues( myBA1, 8 );
          Console.Write( "myBA2:" );
          PrintValues( myBA2, 8 );
          Console.WriteLine();
    
          Console.WriteLine( "Result" );
          Console.Write( "XOR:" );
          PrintValues( myBA1.Xor( myBA2 ), 8 );
          Console.WriteLine();
    
          Console.WriteLine( "After XOR" );
          Console.Write( "myBA1:" );
          PrintValues( myBA1, 8 );
          Console.Write( "myBA2:" );
          PrintValues( myBA2, 8 );
          Console.WriteLine();
    
          // Performing XOR between BitArray instances of different sizes returns an exception.
          try  {
             BitArray myBA3 = new BitArray( 8 );
             myBA3[0] = myBA3[1] = myBA3[2] = myBA3[3] = false;
             myBA3[4] = myBA3[5] = myBA3[6] = myBA3[7] = true;
             myBA1.Xor( myBA3 );
          } catch ( Exception myException )  {
             Console.WriteLine("Exception: " + myException.ToString());
          }
       }
    
    
       public static void PrintValues( IEnumerable myList, int myWidth )  {
          int i = myWidth;
          foreach ( Object obj in myList ) {
             if ( i <= 0 )  {
                i = myWidth;
                Console.WriteLine();
             }
             i--;
             Console.Write( "{0,8}", obj );
          }
          Console.WriteLine();
       }
    
    }
    
    
    /* 
    This code produces the following output.
    
    Initial values
    myBA1:   False   False    True    True
    myBA2:   False    True   False    True
    
    Result
    XOR:   False    True    True   False
    
    After XOR
    myBA1:   False    True    True   False
    myBA2:   False    True   False    True
    
    Exception: System.ArgumentException: Array lengths must be the same.
       at System.Collections.BitArray.Xor(BitArray value)
       at SamplesBitArray.Main()
    
    */ 
    
    
    
    
    
  • 相关阅读:
    iOS开发中TableView的嵌套使用
    iOS弹出View同时使背影变暗
    APNs消息推送完整讲解
    oc学习之路----APNS消息推送从证书到代码(2015年4月26号亲试可用)
    oc学习之路----application.keyWindow.rootViewController与self.window.rootViewController与[self.window makeKeyAndVisible];小发现
    oc学习之路----application.keyWindow.rootViewController与self.window.rootViewController与[self.window makeKeyAndVisible];小发现
    数据库设计原则
    oc学习之路----QQ聊天界面
    oc学习之路----代理模式2-使用步骤
    oc学习之路----通过代码自定义cell
  • 原文地址:https://www.cnblogs.com/i80386/p/2359493.html
Copyright © 2011-2022 走看看