Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Re: Color Drop
Started by bdipso at 02-14-2008 9:29. Topic has 5 replies.

Print Search « Previous Thread Next Thread »
  02-14-2008, 9:29
bdipso is not online. Last active: 2/16/2008 8:59:53 PM bdipso

Not Ranked
Joined on 01-28-2008
Posts 3
Color Drop

Attachment: ba.zip
Reply Quote
Hi, I'm trying to implement a method (using C++ or Delphi) that does something similar to scanner's (Red,Green or blue) "Color Drop" function.

After I drop certain colors (something like all except black) from the image I'll try to OCR it.

Which is the proper function for this purpose? I'm working on L_RemapBitmapHue().

Example images are attached.

   Report 
  02-14-2008, 11:42
GregR is not online. Last active: 11/26/2008 3:40:25 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,717
Re: Color Drop
Reply Quote
The best way to do this would be to select a region based on either a single color or a color range.  To do this:

1.
you can use the L_SetBitmapRgnColor, L_SetBitmapRgnColorRGBRange, or L_SetBitmapRgnColorHSVRange function.  For the combine mode, you would want to use L_RGN_SETNOT so that you select everything BUT the color you selected (let's say you only selected black). 

2.
Then you would use L_FillBitmap to fill the region with white. 

3.
Finally, you would use L_FreeBitmapRgn to delete the regoin from the bitmap before doing anything else.

Greg Ross
LEADTOOLS Technical Support
   Report 
  02-15-2008, 8:20
bdipso is not online. Last active: 2/16/2008 8:59:53 PM bdipso

Not Ranked
Joined on 01-28-2008
Posts 3
Re: Color Drop
Reply Quote
Thank you, it is working like a charm..
   Report 
  02-15-2008, 9:47
bdipso is not online. Last active: 2/16/2008 8:59:53 PM bdipso

Not Ranked
Joined on 01-28-2008
Posts 3
Re: Color Drop

Attachment: middle.zip
Reply Quote
For anybody who wants such a function in Delphi. I used L_RemapBitmapHue() function to convert any pixel that has a less light value than 170 to pure black. Than removed any color but black in the following code :

procedure TMainForm.Button11Click(Sender: TObject);
var
i : integer;
uMaskTable : array [0..255] of L_UINT;
uValTable : array [0..255] of L_UINT;
uLUTLen : L_INT;
nRet : L_INT;
rgbLower : COLORREF;
rgbHigher : COLORREF;
crRgnColor : COLORREF;
fSmooth : SMOOTH;
fDotRemove : DOTREMOVE;
br : BORDERREMOVE;
begin
uLUTLen := 256;
for i:=0 to uLUTLen-1 do
begin
uMaskTable[i] := 1;
if i>170 then
uValTable[i]:=i
else
uValTable[i]:=0;
end;

nRet := L_RemapBitmapHue(@Bitmap1, @uMaskTable, nil, nil, @uValTable, uLUTLen);
if nRet=SUCCESS then begin
rgbLower := RGB(0,0,0);
rgbHigher := RGB(0,0,0);
nRet := L_SetBitmapRgnColorRGBRange(@Bitmap1,rgbLower,rgbHigher,L_RGN_SETNOT);
if (nRet=SUCCESS) then begin
if (L_BitmapHasRgn(@Bitmap1)) then begin
crRgnColor := RGB(255,255,255);
nRet := L_FillBitmap(@Bitmap1, crRgnColor);
if (nRet=SUCCESS) then begin
nRet := L_ColorResBitmap(@Bitmap1, @Bitmap1, sizeof(BITMAPHANDLE)
, 1
, CRF_NODITHERING or CRF_FIXEDPALETTE or CRF_BYTEORDERBGR
, nil, 0, 0, nil, nil);
if nret=Success then begin
HandlePalette ( false );
invalidate;
end;
end;
L_FreeBitmapRgn(@Bitmap1);
end;
end;
end;
end;

   Report 
  10-20-2008, 15:38
psentle is not online. Last active: 10/10/2008 12:54:31 PM psentle

Not Ranked
Joined on 10-10-2008
Posts 1
Re: Color Drop
Reply Quote
Am trying to implement the routine you have provided using Visual Basic, I am unable to call/reference the DLL's that include the functions used above.

How do I reference and access the functions/subroutines used in the above routine of dropping color Visual Basic 6?

Thanks

   Report 
  10-21-2008, 11:57
GregR is not online. Last active: 11/26/2008 3:40:25 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,717
Re: Color Drop
Reply Quote
He is using the CDLL interface, so you need to declare the functions so you can use them in VB6.  This is done the same way that you would any other Windows API function call.  Documentation of the functions and structures can be found in the CDLL (or API if you are using something v15 and older) help files.

Greg Ross
LEADTOOLS Technical Support
   Report 
Post
LEAD Support Fo... » Developer » Color Conversio... » Re: Color Drop

Powered by Community Server, by Telligent Systems