LBitmap::Smooth

#include "ltwrappr.h"

virtual L_INT LBitmap::Smooth(pSmooth)

LPSMOOTH pSmooth;

/* pointer to a structure */

Smooths the bumps and fills in the nicks of a 1-bit black and white image.

This function is available in the Document/Medical Toolkits.

Parameter

Description

pSmooth

Pointer to the SMOOTH structure that LEADTOOLS uses to perform the smoothing operation

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function smooths the text in scanned text documents.

The behavior of this function can be modified by overriding LBitmap::SmoothCallback.

This function works only on 1-bit black and white images.

If a region is selected, only the selected region will be changed by this function. If no region is selected, the whole image will be processed.

This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.

Required DLLs and Libraries

LTIMG

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LBitmap::SmoothCallback, LBitmap::LineRemove, LBitmap::BorderRemove, LBitmap::InvertedText, LBitmap::DotRemove, LBitmap::HolePunchRemove

Topics:

Cleaning Up 1-Bit Images

Example

//This example smooths all nicks and bumps up to 2 pixels in length
//Long bumps/nicks are treated before short bumps/nicks
//A LEAD region is updated to show all the changes.
//The derived class LMyBitmap is used to override the SmoothCallBack function. 
//myBitmap is an object of class LMyBitmap.
//This callback member function is used to display information about bumps or nicks
//The callback member function does NOT receive a Windows region

void CCleanv12Dlg::OnButtonSmooth() 
{
   SMOOTH smooth;
   BITMAPHANDLE BitmapHandle;
   L_INT32      nRet;
   
   smooth.iSize = sizeof (SMOOTH);
   smooth.iLength = 2;
   smooth.pBitmapRegion = &BitmapHandle;

   smooth.uFlags = SMOOTH_SINGLE_REGION | SMOOTH_LEAD_REGION | SMOOTH_FAVOR_LONG;
   nRet = m_Bitmap.Smooth(&smooth);
   
   if (nRet == SUCCESS)
   {
      //Delete the existing region
      LBitmapRgn Region(&m_Bitmap);  
      if(Region.BitmapHasRgn())
      {
         Region.Free();
      }
      
      m_Bitmap.SetHandle(smooth.pBitmapRegion, FALSE); 
      Invalidate();   
   }
}

 

L_INT LMyBitmap::SmoothCallBack(  
                                L_UINT32       uBumpOrNick,
                                L_INT32        iStartRow, 
                                L_INT32        iStartCol, 
                                L_INT32        iLength,
                                L_UINT32       uHorV
                                )
{
   CString  strMsg;
   CString  strHorV;  
   CString  strBumpOrNick;
   
   switch (uBumpOrNick)
   {
   case SMOOTH_BUMP:
      strBumpOrNick = TEXT("Bump");
      break;
      
   case SMOOTH_NICK:
      strBumpOrNick = TEXT("Nick");
      break;
   }
   
   if (uHorV == SMOOTH_HORIZONTAL_ELEMENT)
   {
      strHorV = TEXT("Horizontal");
   }
   else
   {
      strHorV = TEXT("Vertical");
   }
   
   //Note: no hRgn to delete because it was not requested
   strMsg.Format(
      TEXT("Type[%s]\tRow Col[%d, %d]\tLength[%d]\t[%s]\n"), 
      strBumpOrNick,
      iStartRow,
      iStartCol,
      iLength,
      strHorV);
   OutputDebugString(strMsg);
   return SUCCESS_REMOVE;
}