Esempio n. 1
0
        public void RechercheCase()
        {
            updateInfoTraitement(this, "Recherche de case coché : ", "Init...");
            Image<Gray, Byte> imageCase = imageModification.convertionBinaire(lesCorrespondances[lesPagesModeles[0]]);
            Image<Gray, Byte> imageCaseModele = imageModification.convertionBinaire(lesPagesModeles[0].image);

            List<Rectangle> lesCases = new List<Rectangle>();
            List<Rectangle> lesCasesModele = new List<Rectangle>();
            List<String> lesCaseNom = new List<string>();
            List<String> lesCaseMotCle = new List<string>();
            foreach (ZoneInfo uneCase in lesPagesModeles[0].casesACocher)
            {
                if (!lesCaseMotCle.Contains(uneCase.motcle))
                {
                    List<Rectangle> listCaseRect = tesseract.selectRectGauche(imageCase, uneCase.motcle, uneCase.hauteur, uneCase.offset);
                    lesCases.AddRange(listCaseRect);
                    lesCasesModele.AddRange(tesseract.selectRectGauche(imageCaseModele, uneCase.motcle, uneCase.hauteur, uneCase.offset));
                    lesCaseMotCle.Add(uneCase.motcle);
                }
                lesCaseNom.Add(uneCase.nom);
            }

            List<Image<Gray, Byte>> imgCase = new List<Image<Gray, byte>>();
            List<Image<Gray, Byte>> imgModeleCase = new List<Image<Gray, byte>>();

            //int j = 1;
            foreach (Rectangle r in lesCases)
            {
                Image<Gray, Byte> img = imageModification.rogner(imageCase, r);
                imgCase.Add(img);
                //img.Save(cheminTmp + j + ".tif");
                //j++;
            }

            //j = 1;
            foreach (Rectangle r in lesCasesModele)
            {
                Image<Gray, Byte> img = imageModification.rogner(imageCaseModele, r);
                imgModeleCase.Add(img);
                //img.Save(cheminTmp + j + "M.tif");
                //j++;
            }

            MatModification matModification = new MatModification();
            List<Boolean> resultCase = matModification.CaseCoche(imgModeleCase, imgCase);

            for (int i = 0; i < resultCase.Count; i++)
            {
                if (resultCase[i])
                {
                    updateResultatTraitement(this, "Master coché : " + lesCaseNom[i]);
                }
            }
        }
Esempio n. 2
0
        public void RechercheSectionVide()
        {
            updateInfoTraitement(this, "Recherche de section vide : ", "Init...");
            double ratioZoneDeTexte = double.Parse(ConfigurationManager.AppSettings["ratioZoneDeTexte"]);
            MatModification matModification = new MatModification();
            int modifTaille = 20;
            foreach (PageModele modele in lesCorrespondances.Keys)
            {
                updateInfoTraitement(this, "Recherche de section vide : ", "Page " + modele.numero);
                Image<Gray, Byte> image = imageModification.convertionBinaire(lesCorrespondances[modele]);
                Image<Gray, Byte> imageModele = imageModification.convertionBinaire(modele.image);
                int i = 1;
                foreach (ZoneInfo sectionInfo in modele.zoneInfos)
                {
                    Rectangle sectionRect = tesseract.selectRectAllFirst(image, sectionInfo.motcle, sectionInfo.hauteur + modifTaille, sectionInfo.offset - modifTaille);
                    Rectangle sectionModeleRect = tesseract.selectRectAllFirst(imageModele, sectionInfo.motcle, sectionInfo.hauteur + modifTaille, sectionInfo.offset - modifTaille);

                    //Console.WriteLine(sectionInfo.nom + " => " + sectionRect + " - " + sectionModeleRect);

                    Image<Gray, Byte> imgSection = imageModification.rogner(image, sectionRect);
                    Image<Gray, Byte> imgSectionModele = imageModification.rogner(imageModele, sectionModeleRect);
                    //imgSection.Save(cheminTmp + modele.numero + i + ".tif");
                    //imgSectionModele.Save(cheminTmp + modele.numero + i + "M.tif");
                    i++;

                    double ratio = matModification.RatioPixelsNoir(imgSection, imgSectionModele);
                    //Console.WriteLine(ratio);

                    //Console.Write(sectionInfo.nom + " ");
                    if (ratio < ratioZoneDeTexte)
                    {
                        //Console.WriteLine("ok");
                    }
                    else
                    {
                        Console.Write(sectionInfo.nom + " ");
                        Console.WriteLine("ko");
                    }
                }
            }
        }
Esempio n. 3
0
        public void decoupeRubrique()
        {
            updateInfoTraitement(this, "Découpage de rubrique : ", "Init...");
            lesRubriques = new Dictionary<PageModele, Dictionary<string, Image<Gray, byte>>>();
            MatModification matModification = new MatModification();
            int modifTaille = 20;
            List<Image<Gray, Byte>> corresCopy = new List<Image<Gray, byte>>();
            corresCopy.AddRange(lesImagesNum);
            foreach (PageModele modele in lesCorrespondances.Keys)
            {
                updateInfoTraitement(this, "Découpage de rubrique : ", "Page " + modele.numero);
                Image<Gray, Byte> image = imageModification.convertionBinaire(lesCorrespondances[modele]);

                Dictionary<String, Image<Gray, byte>> modeleRubriques = new Dictionary<string, Image<Gray, byte>>();
                //int i = 1;
                foreach (ZoneInfo rubriqueInfo in modele.rubriques)
                {
                    Rectangle rubriqueRect = tesseract.selectRectAllFirst(image, rubriqueInfo.motcle, rubriqueInfo.hauteur + modifTaille, rubriqueInfo.offset - modifTaille);
                    Image<Gray, Byte> imgRubrique = imageModification.rogner(lesCorrespondances[modele], rubriqueRect);
                    //imgRubrique.Save(cheminTmp + modele.numero + i + "-" + rubriqueInfo.nom + ".tif");
                    modeleRubriques.Add(rubriqueInfo.nom, imgRubrique);
                    //i++;
                }
                lesRubriques.Add(modele, modeleRubriques);
                corresCopy.Remove(lesCorrespondances[modele]);
            }
            /*
            int j = 1;
            foreach(Image<Gray, Byte> annexe in corresCopy)
            {
                annexe.Save(cheminTmp + "annexe-" + j + ".tif");
                j++;
            }
            */
        }