66 return pixCreate(pixGetWidth(pix), pixGetHeight(pix), 1);
69 Pix *pixr = pixReduceRankBinaryCascade(pix, 1, 0, 0, 0);
70 if (textord_tabfind_show_images && pixa_debug !=
nullptr)
71 pixa_debug->AddPix(pixr,
"CascadeReduced");
81 return pixCreate(pixGetWidth(pix), pixGetHeight(pix), 1);
85 Pixa* pixadb = (textord_tabfind_show_images && pixa_debug !=
nullptr)
88 Pix* pixht2 = pixGenerateHalftoneMask(pixr,
nullptr, &ht_found, pixadb);
90 Pix* pixdb = pixaDisplayTiledInColumns(pixadb, 3, 1.0, 20, 2);
91 if (textord_tabfind_show_images && pixa_debug !=
nullptr)
92 pixa_debug->AddPix(pixdb,
"HalftoneMask");
97 if (!ht_found && pixht2 !=
nullptr)
99 if (pixht2 ==
nullptr)
100 return pixCreate(pixGetWidth(pix), pixGetHeight(pix), 1);
103 Pix *pixht = pixExpandReplicate(pixht2, 2);
104 if (textord_tabfind_show_images && pixa_debug !=
nullptr)
105 pixa_debug->AddPix(pixht,
"HalftoneReplicated");
109 Pix *pixt = pixSeedfillBinary(
nullptr, pixht, pix, 8);
110 pixOr(pixht, pixht, pixt);
114 Pix* pixfinemask = pixReduceRankBinaryCascade(pixht, 1, 1, 3, 3);
115 pixDilateBrick(pixfinemask, pixfinemask, 5, 5);
116 if (textord_tabfind_show_images && pixa_debug !=
nullptr)
117 pixa_debug->AddPix(pixfinemask,
"FineMask");
118 Pix* pixreduced = pixReduceRankBinaryCascade(pixht, 1, 1, 1, 1);
119 Pix* pixreduced2 = pixReduceRankBinaryCascade(pixreduced, 3, 3, 3, 0);
120 pixDestroy(&pixreduced);
121 pixDilateBrick(pixreduced2, pixreduced2, 5, 5);
122 Pix* pixcoarsemask = pixExpandReplicate(pixreduced2, 8);
123 pixDestroy(&pixreduced2);
124 if (textord_tabfind_show_images && pixa_debug !=
nullptr)
125 pixa_debug->AddPix(pixcoarsemask,
"CoarseMask");
127 pixAnd(pixcoarsemask, pixcoarsemask, pixfinemask);
128 pixDestroy(&pixfinemask);
130 pixDilateBrick(pixcoarsemask, pixcoarsemask, 3, 3);
131 Pix* pixmask = pixExpandReplicate(pixcoarsemask, 16);
132 pixDestroy(&pixcoarsemask);
133 if (textord_tabfind_show_images && pixa_debug !=
nullptr)
134 pixa_debug->AddPix(pixmask,
"MaskDilated");
136 pixAnd(pixht, pixht, pixmask);
137 pixDestroy(&pixmask);
138 if (textord_tabfind_show_images && pixa_debug !=
nullptr)
139 pixa_debug->AddPix(pixht,
"FinalMask");
141 Pix* result = pixCreate(pixGetWidth(pix), pixGetHeight(pix), 1);
142 pixOr(result, result, pixht);