• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Post reply

Other options

Shortcuts: ALT+S save/post or ALT+P preview

Topic summary

Posted by Galfar
 -  7 August 2007, 23:41:12
I have looked at Tesseract's API and found TessDllBeginPageBPP function which accepts 1, 8, and 24 bit images so I guess 1 bit images are not the only option (using DLL).
Command line app seems to read only TIFFs but it is not limited to 1 bit per pixel either.
I have not tested it though so I may be wrong.
Posted by Galfar
 - 20 July 2007, 13:23:49
Lua binding sounds good, I'm interested. Please send it to me when it is ready (some small example would be nice too). I will add it to Extras directory.
Posted by jdarling
 - 18 July 2007, 15:42:29
Hey Galf, sorry it took so long to reply I've been busy on another project that had immediate attention needs :).  Anyways, the library I'm using is called Tesseract and can be found at http://code.google.com/p/tesseract-ocr/

Seems to work well, but does have its limitations (like I can't figure out how to use iterative training with the damned thing).

On another note, I've been working on wrapping up a lot of the Vampyer stuff to I can use it from my Lua scripts inside our application.  Any chance you would be interested in the code when its complete?  It would require anyone using it to have my version of the Lua headers or to make sure that they have support for the proper libraries (I think the JEDI version would also work), but it may be useful to people who need to do image manipulation within their Pascal projects using Lua scripting.
Posted by Galfar
 -  6 July 2007, 22:56:50
Here is the code to convert image to 1 bit per pixel black and white image:


var
  Img: TSingleImage;
  Src, Bitmap: PByte;
begin

... load or create image ...

// First convert image to 8bpp grayscale
Img.Format := ifGray8;
Src := Img.Bits;

// Create bilevel image using 128 as treshold
for Y := 0 to Img.Height - 1 do
  for X := 0 to Img.Width - 1 do
  begin
    if Src^ > 128 then
      Src^ := 255
    else
      Src^ := 0;
    Inc(Src);
  end;

// Allocate memory for 1bpp image
WidthBytes := (Img.Width + 7) div 8;  // Scanlines size must be byte-aligned
GetMem(Bitmap, WidthBytes * Img.Height);
FillChar(Bitmap^, WidthBytes * Img.Height, 0);  // Needed by conversion code
Src := Img.Bits;

// Now copy pixels to Bitmap
for Y := 0 to Img.Height - 1 do
  for X := 0 to Img.Width - 1 do
  begin
    Bitmap[Y * WidthBytes + X div 8] := Bitmap[Y * WidthBytes + X div 8] or // OR current value of byte with following:
      (Src^ and 1)  // To make 1 from 255, 0 remains 0
      shl (7 - (X mod 8));  // Put current bit to proper place in byte

    Inc(Src);
  end;

Now you have 1bpp image in Bitmap memory. You may need to use different treshold than 128 for
different images.

QuoteJust have to look at the API.

Do you have some link to where can I get it? I've tried google but not found anything useful.


Posted by jdarling
 -  5 July 2007, 20:39:33
Saved to file would be nice, but I can work with it in memory as well.  Right now I'm calling a command line OCR application, but it has a DLL that can be put in its place.  Just have to look at the API.
Posted by Galfar
 -  4 July 2007, 18:00:18
Do you need 1bit images only in memory or saved to files too?
If only keeping them in memory is needed I can post here how to do it.
Otherwise file format saver would have to be modified.
I am planning native support for 1/2/4 bit images in entire library (not only loading)
in the future but it would take time.

Does Triss only accept 1bit images or some other bilevel or similar formats too?
Posted by jdarling
 -  2 July 2007, 18:24:36
I've been playing with OCR and the Triss library.  I'm finally ready to incorporate Triss into my application but need to be able to generate 1 bit black and white bitmaps in order to run the OCR against the images.  Can anyone explain how to use Vamp to do this?

Thanks,
- Jeremy
SMF spam blocked by CleanTalk