Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.24
LEADTOOLS Raster imaging C++ Class library help

LBitmap::ShiftZeroToNegative

Show in webframe

#include "ltwrappr.h"

L_INT LBitmap::ShiftZeroToNegative(nShiftAmount, nMinInput, nMaxInput, nMinOutput, nMaxOutput, uFlags = 0)

L_INT nShiftAmount;

/* shifting amount */

L_INT nMinInput;

/* bitmaps minimum value */

L_INT nMaxInput;

/* bitmaps maximum value */

L_INT nMinOutput;

/* minimum allowed value */

L_INT nMaxOutput;

/* maximum allowed value */

L_UINT32 uFlags;

/* flags */

Converts an unsigned bitmap to a signed bitmap by decreasing intensity values by a specific amount.

Parameter

Description

nShiftAmount

The amount by which to decrease the bitmap's intensity values. This value is used to shift the bitmap data to include negative values.

nMinInput

The bitmap's minimum intensity value. This value can be obtained by calling the LBitmap::GetMinMaxVal function.

nMaxInput

The bitmap's maximum intensity value. This value can be obtained by calling the LBitmap::GetMinMaxVal function.

nMinOutput

The minimum intensity value allowed in the resulting image. If this function results in an intensity value less than this value, the intensity value in the resulting image will be set to this minimum value.

nMaxOutput

The maximum intensity value allowed in the resulting image. If this function results in an intensity value more than this value, the intensity value in the resulting image will be set to this maximum value.

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

By decreasing the intensity values of the bitmap (creating some negative values), a value of zero in the original bitmap would be shifted to a value of nShiftAmount.

This function is similar to LBitmap::ConvertUnsignedToSigned. However, LBitmap::ShiftZeroToNegative lets the user determine the value by which to shift the data, while in LBitmap::ConvertUnsignedToSigned, the shift is fixed always. (i.e. shift center to zero.)

The LBitmap::ShiftMinimumToZero and LBitmap::ShiftZeroToNegative are most often used in concert with one or more image processing or analysis functions. LBitmap::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, LBitmap::ShiftZeroToNegative converts the unsigned data back to signed data.

This function updates the "Flags.Signed", "MinVal" and "MaxVal" members of the class objects BITMAPHANDLE member; a pointer obtained by calling LBitmapBase::GetHandle function.

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 only in the Document/Medical toolkits.

This function supports signed data images.

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.

See Also

Functions:

LBitmapBase::ClearNegativePixels, LBitmap::ConvertUnsignedToSigned, LBitmap::ConvertSignedToUnsigned, LBitmap::ShiftMinimumToZero

Topics:

Raster Image Functions: Getting and Setting Pixel Values

 

Processing an Image

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT LBitmap__ShiftZeroToNegativeExample()
{
   // This function will apply LBitmap::MultiScaleEnhancementBitmap on a signed image, 
   // but since LBitmap::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. 
   L_UINT         nShiftAmount; 
   LBitmap        LeadBitmap; 
   L_INT          nRet; 
   LOADFILEOPTION LoadFileOption; 
   
   /* enable negative pixels to be loaded from TIFF files */
   nRet =LBaseFile::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 =LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("SignedBtimap.dcm")), 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 =LeadBitmap.ShiftMinimumToZero(&nShiftAmount);
   if(nRet !=SUCCESS)
      return nRet;
   
   // Apply multiscale enhancement
   nRet =LeadBitmap.MultiScaleEnhancement( 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 =LeadBitmap.ShiftZeroToNegative( nShiftAmount, -32767, 32766, 0, 65535);
   if(nRet !=SUCCESS)
      return nRet;
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.