L_ShiftZeroToNegative
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_ShiftZeroToNegative(pBitmap, nShiftAmount, nMinInput, nMaxInput, nMinOutput, nMaxOutput)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
L_INT nShiftAmount; |
/* shifting amount */ |
L_INT nMinInput; |
/* bitmap’s minimum value */ |
L_INT nMaxInput; |
/* bitmap’s maximum value */ |
L_INT nMinOutput; |
/* minimum allowed value */ |
L_INT nMaxOutput; |
/* maximum allowed value */ |
Converts an unsigned bitmap to a signed bitmap by decreasing intensity values by a specific amount. This function is available in the Raster Pro and above toolkits.
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle referencing the bitmap to convert. |
nShiftAmount |
The amount by which to decrease the bitmap's intensity values. The amount that is used to shift the bitmap data to the negative side. |
nMinInput |
The bitmap's minimum intensity value. This value can be obtained by calling the L_GetMinMaxVal function. |
nMaxInput |
The bitmap's maximum intensity value. This value can be obtained by calling the L_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. |
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 L_ConvertBitmapUnsignedToSigned. However, L_ShiftZeroToNegative lets the user determine the value by which to shift the data, while in L_ConvertBitmapUnsignedToSigned, the shift is fixed always. (i.e. shift center to zero.)
This function is used usually after the function L_ShiftMinimumToZero.
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 doesn’t 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.
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. |
Platforms
Windows 95 / 98 / Me, Windows 2000 / XP.
See Also
Functions: |
L_ClearNegativePixels, L_ConvertBitmapUnsignedToSigned, L_ConvertBitmapSignedToUnsigned, L_ShiftMinimumToZero |
Topics: |
|
|
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.
L_INT nShiftAmount;
BITMAPHANDLE LeadBitmap;
L_INT nRet;
LOADFILEOPTION LoadFileOption;
/* enable negative pixels to be loaded from TIFF files */
L_GetDefaultLoadFileOption (&LoadFileOption, sizeof(LOADFILEOPTION));
LoadFileOption.Flags |= ELO_SIGNED;
/* Load the bitmap, keeping the bits per pixel of the file */
L_LoadBitmap (TEXT("IMAGE1.TIF"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, &LoadFileOption, NULL);
// Convert the bitmap to unsigned bitmap by shifting the negative values to become positive.
nRet = L_ShiftMinimumToZero (&LeadBitmap, &nShiftAmount);
// Apply multiscale enhancement
L_MultiScaleEnhancementBitmap (&LeadBitmap, 2000, 4, MSE_DEFAULT , 0, 0, MSE_GAUSSIAN | MSE_EDGEENH);
// Convert the bitmap back to signed by shifting the same amount in the negative side.
nRet = L_ShiftZeroToNegative(&LeadBitmap, nShiftAmount, -32767, 32766, 0, 65535);