zoukankan      html  css  js  c++  java
  • 使用tesseract識別簡單的圖形碼

    圖示:

      

     運行效果:

      

     實現代碼:

      

    Add-Type -AssemblyName System.Drawing
    function Identify ($path)
    {
        $img=[System.Drawing.Bitmap]::FromFile($path)
    
        for ($i = 0; $i -lt $img.Width; $i++)
        { 
            for ($j = 0; $j -lt $img.Height; $j++)
            { 
                $_p =$img.GetPixel($i,$j)
                $_pt=($_p.R+$_p.G+$_p.B)/3  #灰度值
                if ($_pt -lt 140) #小於閥值 黑色
                {
                    $img.SetPixel($i,$j,[System.Drawing.Color]::FromArgb($_p.A,0,0,0))  
                 }
                 else
                 {#大於閥值設為 白色
                  $img.SetPixel($i,$j,[System.Drawing.Color]::FromArgb($_p.A,255,255,255))  
                 }
            }
        }
        $newPath=$path.Substring(0,$path.LastIndexOf('.'))+'copy1.jpg'
        $img.Save($newPath)
        tesseract $newPath stdout
        Remove-Item $newPath -Force  #刪除處理後的副本
    }

    補充:

      下載地址:https://digi.bib.uni-mannheim.de/tesseract/
      argb:ARGB 是一种色彩模式,也就是RGB色彩模式附加上Alpha(透明度)通道,常见于32位位图的存储结构。


  • 相关阅读:
    Kettle学习(2)
    kettle学习(1)
    Quartz在Spring中的使用
    JVM垃圾收集简介
    快速排序

    20190827最新论文
    GNN
    Multimodal Machine Learning
    Wasserstein距离 及两多元高斯分布间的W距离
  • 原文地址:https://www.cnblogs.com/feiyucha/p/12040188.html
Copyright © 2011-2022 走看看