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 : Wednesday, May 17, 2017 1:13:37 AM(UTC)
PappaSmurf

Groups: Registered
Posts: 2


In attempting to us the C API L_DeskewBitmap as well as L_DespeckleBitmap, I was wondering when using a MultiPage TIF file is the Scope of the Functions the entire image, regardless of the number of pages contained within.

Or do I need to split the document into x number of pages and run the command against each pages image?


PappaSmurf
 

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 : Friday, May 19, 2017 6:52:50 AM(UTC)

Walter  
Walter

Groups: Tech Support
Posts: 366

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)

Hello PappaSmurf,

All of our image processing methods are done per page. So with multi-page documents (i.e. a bitmap list), you would need to cycle through all pages and run the command on each page to hit each image within the list.

The following example from L_CreateBitmapList() doesn't exactly illustrate what you would need to do, but it does illustrate using image processing on a single image. The example then puts the individual BITMAPHANDLE into the BITMAPLIST:
Code:

   /* Create and populate the bitmap list */
   nRet = L_CreateBitmapList(&hList);
   if(nRet !=SUCCESS)
      return nRet;
   for (i = 0; i <= 36; ++ i)
   {
      nRet = L_CopyBitmap(&TmpBitmap, pBitmap, sizeof(BITMAPHANDLE));
      if(nRet !=SUCCESS)
         return nRet;
      /* Rotate, using the transparent color as the fill color */
      nRet = L_RotateBitmap (&TmpBitmap, 1000 * i, 0, PALETTEINDEX(255));
      if(nRet !=SUCCESS)
         return nRet;
      nRet = L_InsertBitmapListItem(hList, (L_UINT)-1, &TmpBitmap);
      if(nRet !=SUCCESS)
         return nRet;
   }


This snippet from the example for L_GetBitmapListItem() is probably a little better example to look at here:
Code:

   nRet = L_GetBitmapListCount(hList, &uCount);
   if(nRet != SUCCESS)
      return nRet;

   for (i = 0; i < uCount; ++i)
   {
      nRet = L_GetBitmapListItem(hList, i, &TmpBitmap, sizeof(BITMAPHANDLE));
      if(nRet != SUCCESS)
         return nRet;

      nRet = L_ChangeBitmapHue(&TmpBitmap, i * 10, 0);
      if(nRet != SUCCESS)
         return nRet;

      if(TmpBitmap.BitsPerPixel<=8)
      {
         nRet = L_PutBitmapColors(&TmpBitmap, 255, 1, TransparentColor);
         if(nRet != SUCCESS)
            return nRet;
      }

      nRet = L_SetBitmapListItem(hList, i, &TmpBitmap);
      if(nRet != SUCCESS)
         return nRet;
   }


Code:

   nRet = L_GetBitmapListCount(hList, &uCount);
   if(nRet != SUCCESS)
      return nRet;

   for (i = 0; i < uCount; ++i)
   {
      /* Get the bitmap */
      nRet = L_GetBitmapListItem(hList, i, &TmpBitmap, sizeof(BITMAPHANDLE));
      if(nRet != SUCCESS)
         return nRet;

      /* Deskew the bitmap */
      nRet = L_DeskewBitmap(&TmpBitmap, NULL, 0, DSKW_PROCESS | DSKW_NOFILL | DSKW_RESAMPLE | DSKW_DOCUMENTIMAGE);
      if(nRet !=SUCCESS)
            return nRet;

      /* Remove speckles from the bitmap */
      nRet = L_DespeckleBitmap(&TmpBitmap, 0);
      if(nRet !=SUCCESS)
            return nRet;

      /* Update the list */
      nRet = L_SetBitmapListItem(hList, i, &TmpBitmap);
      if(nRet != SUCCESS)
         return nRet;
   }


p.s. If you're wondering why I left the first two examples in, I figured I might as well leave the references to the functions in since they may be useful to you or anyone else who comes across this post.

Edited by moderator Wednesday, January 6, 2021 9:19:49 AM(UTC)  | Reason: Not specified

Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#3 Posted : Saturday, May 20, 2017 4:03:59 PM(UTC)
PappaSmurf

Groups: Registered
Posts: 2


Walter

I want to thank you very much for your response and the code snippets that you have provided, it does answer my question about the scope of the commands. I do have a follow on question concerning the order of the commands, is it better to Deskew first and then Despeckle or the reverse of Despeckle then Deskew?

PappaSmurf
 
#4 Posted : Monday, May 22, 2017 11:53:08 AM(UTC)

Walter  
Walter

Groups: Tech Support
Posts: 366

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)

PappaSmurf,

With respect to deskewing and despeckling, I honestly don't think it matters. The despeckling removes 1 pixel specks, so the orientation of the image doesn't make any difference in that case. Whether you're searching up/down/left/right/diagonally, the speck will look exactly the same. The documentation also indicates that it will shrink some larger speckles. So I don't think the order will make any difference here.

My personal preference would be to deskew first and then despeckle afterwards, but that's just my preference.
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
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.068 seconds.