Esempio n. 1
0
        /// <summary>
        /// ノイズ除去
        /// </summary>
        /// <param name="orgImg"></param>
        /// <returns></returns>
        public static Bitmap EraseNoise(Bitmap orgImg)
        {
            IDocumentSDKComponent docSdk = DocumentSDKFactory.GetDocumentSDK();
            Bitmap targetImg             = orgImg.Clone(new Rectangle(0, 0, orgImg.Width, orgImg.Height), System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
            // ノイズ除去処理
            DocumentSDKArea area = new DocumentSDKArea()
            {
                xs = 0,
                ys = 0,
                xe = targetImg.Width - 1,
                ye = targetImg.Height - 1
            };

            using (Image chgimg = docSdk.EraseNoise(targetImg, area, NoiseEnv.ToDocumentSDKEnshParam()))
            {
                return((Bitmap)chgimg.Clone());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// OMR認識処理
        /// </summary>
        /// <param name="itemImage">項目画像</param>
        /// <param name="recogItem">認識対象情報</param>
        /// <returns>OMR認識結果</returns>
        public DocumentSDKOmrResult executeOmr(Image itemImage, DocumentSDKCheckType markType, Rectangle markArea, Image masterImg, Rectangle masterRect)
        {
            IDocumentSDKComponent documentSDK = DocumentSDKFactory.GetDocumentSDK();
            FileStream            stream      = null;
            Image masterImage = null;
            List <DocumentSDKArea> areaList       = new List <DocumentSDKArea>();
            List <DocumentSDKArea> masterAreaList = null;

            try
            {
                // OMRパラメーターの設定
                DocumentSDKOmrParam param = new DocumentSDKOmrParam()
                {
                    check_num    = DocumentSDKDefinition.OMR_CN_UNKNOWN,
                    check_type   = markType,
                    threshold    = SByte.Parse("50"),
                    area_type    = DocumentSDKAreaType.OMR_AT_SOLID,
                    around_area  = DocumentSDKAroundArea.OMR_AA_UNKNOWN,
                    check_size_x = DocumentSDKDefinition.OMR_CS_UNKNOWN,
                    check_size_y = DocumentSDKDefinition.OMR_CS_UNKNOWN,
                };

                // OMR領域を設定(文字領域を抽出され場合、OCRの文字領域を使用する)
                DocumentSDKArea area = new DocumentSDKArea()
                {
                    xs = markArea.Left,
                    ys = markArea.Top,
                    xe = markArea.Left + markArea.Width - 1,
                    ye = markArea.Top + markArea.Height - 1,
                };
                areaList.Add(area);
                if (markType == DocumentSDKCheckType.OMR_CT_UNKNOWN)
                {
                    masterImage    = masterImg;
                    masterAreaList = new List <DocumentSDKArea>();
                    DocumentSDKArea masterArea = new DocumentSDKArea()
                    {
                        xs = masterRect.X,
                        ys = masterRect.Y,
                        xe = masterRect.X + masterRect.Width,
                        ye = masterRect.Y + markArea.Height,
                    };
                    masterAreaList.Add(masterArea);
                }

                // OMR処理の実行
                DocumentSDKOmrResult result = documentSDK.ExecuteOmr(itemImage, areaList, masterImage, masterAreaList, param);

                return(result);
            }
            finally
            {
                // ファイルストリームの破棄
                if (stream != null)
                {
                    stream.Dispose();
                }
                // マスター画像の破棄
                if (masterImage != null)
                {
                    masterImage.Dispose();
                }
            }
        }