Welcome to LEAD Support Forum Login | Register | Faq  

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

Color Drop
Started by bdipso at 02-14-2008 9:29. Topic has 3 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: 9/30/2008 12:26:32 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,607
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 
Post
LEAD Support Fo... » Developer » Color Conversio... » Color Drop

Powered by Community Server, by Telligent Systems