Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, February 14, 2008 4:24:04 AM(UTC)

bdipso  
bdipso

Groups: Registered
Posts: 3


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.
File Attachment(s):
ba.zip (49kb) downloaded 21 time(s).
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, February 14, 2008 6:37:47 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


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.
 
#3 Posted : Friday, February 15, 2008 3:15:46 AM(UTC)

bdipso  
bdipso

Groups: Registered
Posts: 3


Thank you, it is working like a charm..
 
#4 Posted : Friday, February 15, 2008 4:42:46 AM(UTC)

bdipso  
bdipso

Groups: Registered
Posts: 3


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;
File Attachment(s):
middle.zip (171kb) downloaded 21 time(s).
 
#5 Posted : Monday, October 20, 2008 10:33:04 AM(UTC)

psentle  
psentle

Groups: Registered
Posts: 1


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
 
#6 Posted : Tuesday, October 21, 2008 6:52:38 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


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.
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.117 seconds.