Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_ShiftMinimumToZero

Show in webframe

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_ShiftMinimumToZero(pBitmap, puShiftAmount, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_UINT *puShiftAmount;

/* pointer to the shifting amount */

L_UINT32 uFlags;

/* flags */

Converts the signed bitmap to an unsigned bitmap by increasing/shifting the bitmap's intensity values, so the lowest intensity value (the most negative value) will be shifted to zero.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap to convert.

puShiftAmount

Pointer to a variable to be updated with the value by which the intensity values were shifted.

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function is similar to L_ConvertBitmapSignedToUnsigned. However, L_ShiftMinimumToZero updates the puShiftAmount parameter with the value by which the intensity values were shifted.

The L_ShiftMinimumToZero and L_ShiftZeroToNegative are most often used in concert with one or more image processing or analysis functions. L_ShiftMinimumToZero converts signed data to unsigned data, in preparation for some image processing or analysis. (Most image processing functions work only on unsigned data.) After the image processing or analysis is performed, L_ShiftZeroToNegative converts the unsigned data back to signed data.

This function updates the pBitmap->Flags.Signed, MinVal and MaxVal members of the BITMAPHANDLE.

This function doesnt support 8-bit images.

This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available in the Document and Medical Imaging toolkits.

This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.

Required DLLs and Libraries

LTIMGCOR

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

Platforms

Win32, x64, Linux.

See Also

Functions:

L_ClearNegativePixels, L_ConvertBitmapUnsignedToSigned, L_ConvertBitmapSignedToUnsigned, L_ShiftZeroToNegative

Topics:

Raster Image Functions: Getting and Setting Pixel Values

 

Processing an Image

Example

This function will apply L_MultiScaleEnhancementBitmap on a signed image, but since L_MultiScaleEnhancementBitmap doesn't support signed images, we will convert the image to unsigned image, apply the effect, and then convert it back to signed image.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


#if defined (LEADTOOLS_V16_OR_LATER)
 L_INT ShiftMinimumToZeroExample(L_VOID)
{
   L_UINT nShiftAmount; 
   BITMAPHANDLE LeadBitmap; 
   L_INT nRet; 
   LOADFILEOPTION LoadFileOption; 

   /* enable negative pixels to be loaded from TIFF files */
   nRet = L_GetDefaultLoadFileOption (&LoadFileOption, sizeof(LOADFILEOPTION)); 
   if(nRet !=SUCCESS)
      return nRet;
   LoadFileOption.Flags |= ELO_SIGNED; 

   /* Load the bitmap, keeping the bits per pixel of the file */
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("clean.tif")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, &LoadFileOption, NULL); 
   if(nRet !=SUCCESS)
      return nRet;

// Convert the bitmap to unsigned bitmap by shifting the negative values to become positive. 
   nRet = L_ShiftMinimumToZero(&LeadBitmap, &nShiftAmount, 0); 
   if(nRet !=SUCCESS)
      return nRet;

   // Apply multiscale enhancement
   nRet = L_MultiScaleEnhancementBitmap (&LeadBitmap, 2000, 4, MSE_DEFAULT , 0, 0, MSE_GAUSSIAN | MSE_EDGEENH); 
   if(nRet !=SUCCESS)
      return nRet;
   
// Convert the bitmap back to signed by shifting the same amount in the negative side. 
   nRet = L_ShiftZeroToNegative(&LeadBitmap, nShiftAmount, -32767, 32766, 0, 65535, 0);
   if(nRet !=SUCCESS)
      return nRet;

   //free bitmap 
   if(LeadBitmap.Flags.Allocated)  
      L_FreeBitmap(&LeadBitmap);  
   return SUCCESS;
}
#else
 L_INT ShiftMinimumToZeroExample(L_VOID)
{
   L_UINT nShiftAmount; 
   BITMAPHANDLE LeadBitmap; 
   L_INT nRet; 
   LOADFILEOPTION LoadFileOption; 

   /* enable negative pixels to be loaded from TIFF files */
   nRet = L_GetDefaultLoadFileOption (&LoadFileOption, sizeof(LOADFILEOPTION)); 
   if(nRet !=SUCCESS)
      return nRet;
   LoadFileOption.Flags |= ELO_SIGNED; 

   /* Load the bitmap, keeping the bits per pixel of the file */
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("clean.tif")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, &LoadFileOption, NULL); 
   if(nRet !=SUCCESS)
      return nRet;

// Convert the bitmap to unsigned bitmap by shifting the negative values to become positive. 
   nRet = L_ShiftMinimumToZero(&LeadBitmap, &nShiftAmount); 
   if(nRet !=SUCCESS)
      return nRet;

   // Apply multiscale enhancement
   nRet = L_MultiScaleEnhancementBitmap (&LeadBitmap, 2000, 4, MSE_DEFAULT , 0, 0, MSE_GAUSSIAN | MSE_EDGEENH); 
   if(nRet !=SUCCESS)
      return nRet;
   
// Convert the bitmap back to signed by shifting the same amount in the negative side. 
   nRet = L_ShiftZeroToNegative(&LeadBitmap, nShiftAmount, -32767, 32766, 0, 65535);
   if(nRet !=SUCCESS)
      return nRet;

   //free bitmap 
   if(LeadBitmap.Flags.Allocated)  
      L_FreeBitmap(&LeadBitmap);  
   return SUCCESS;
}
#endif // LEADTOOLS_V16_OR_LATER
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.