Tulon wrote:I've extended the adjustment range to [-30 .. +30] in 0.9.8.
Separation into text / non text images and postprocessing using 3rd party software would be your last resort.
Great! ST's output will be even better! I'm actually resorting to postprocessing, because it's so hard to get the pictures right with my scanner, that I tuned its settings in a way that kinda messes the text a bit. My reasoning is that it's much easier to fix the text later (hence the need to get it in a separate image) + once the first page is fixed, a Photoshop action can do the rest for me.
Tulon wrote:And no, you can't just take the automask file and draw polygons from the project file on top of it. That's because those polygons are in the coordinate system of the input, not output image.
I think you mean the opposite. I'm using the coordinates from the <
output><page id><zones><zone><spline> node, and do the processing on the output from ST configured with : "Color / Grayscale", no descpeckling (I go in Mixed mode just to get the zones, save the project, and then do the processing in color mode without saving the project again. I know, I'm
like that).
Tulon wrote:Anyway, there is a simple (for a programmer) way to extract picture mask right from the output file. You just read it pixel by pixel and set the corresponding pixel of the mask to 1 if your output pixel is not pure black or pure white, and 0 otherwise.
I know, that's exactly what I did!
As I said, I already coded it. It's easy with CxImage, see:
Code: Select all
DWORD height = mask.GetHeight();
DWORD width = mask.GetWidth();
POINT points[4];
points[0].x=width-1059; points[0].y=height-2621;
points[1].x=width-2400; points[1].y=height-2598;
points[2].x=width-2309; points[2].y=height-3094;
points[3].x=width-1077; points[3].y=height-3098;
image.SelectionAddPolygon(points, 4);
imPic.Copy(image); // picture layer
// Apply mask. image becomes text layer:
RGBQUAD pixColor, rgbWhite = {255,255,255,0};
for (DWORD x = 1; x <= width; x++) {
for (DWORD y = 1; y <= height; y++) {
pixColor = mask.GetPixelColor(x, y, false);
if (pixColor.rgbBlue || image.SelectionIsInside(x, y)) // black==0, white==255
image.SetPixelColor(x, y, rgbWhite, true);
else
imPic.SetPixelColor(x, y, rgbWhite, true);
}
}
// Save result
if ( image.Save("image_txt.tif", CXIMAGE_FORMAT_TIF) )
cout << "Successfully saved text layer to image_txt.tif" << endl;
else { cout << "Saving text layer failed !" << endl; ret = 1; }
if ( imPic.Save("image_pic.tif", CXIMAGE_FORMAT_TIF) )
cout << "Successfully saved picture layer to image_pic.tif" << endl;
else { cout << "Saving picture layer failed !" << endl; ret = 1; }
It works perfectly.
(Regarding the extraction of the coordinates from the project file, don't ask me
I should use some XML parser, but I rather flatten the file up with rxp (using Cygwin) and pipe it into an Awk script, The awk script is ugly, but I'm actually so good with Unix scripting (ksh, awk, sed, & co.) that it costs me almost zero effort. Laziness is sweet
).
Bottom line, I'm
only using ST for automatic deskew, content selection & graphics zones identification.
I take care of ALL the rest myself! You should be ashamed!
Seriously, you already did a tremendous amount of work, so don't bother yourself with this, and focus on 0.9.8!