L_INT LBitmap::Slice(pOptions, pnDeskewAngle, uFlags = 0)
Extracts individual slices from radiographic scanned film.
Pointer to the SLICEBITMAPOPTIONS structure that LEADTOOLS uses to slice the bitmap.
NULL or the address of the variable to be updated with the amount that the function rotates the sliced bitmap. The amount of rotation is expressed in hundredths of degrees. For example, 500 means 5 degrees clockwise. You can pass NULL if you do not need to check the amount of rotation. This field is updated only if SLC_DESKEW is selected from pSLICEBITMAPOPTIONS flag parameter.
Reserved for future use. Must be 0.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Please note that this function is not currently supported in the C++ Class Library. However, this functionality can be implemented by calling the C API function directly. The following code sample indicates how to call the C API function from your code:
/*The following example finds all the slices inside some radiographic scanned film and saves them to the selected folder:*/
typedef struct tagSLICEBITMAPUSERINFO
{
L_CHAR SlicesFolder[L_MAX_PATH];
L_UINT SlicesCount;
} SLICEBITMAPUSERINFO, * pSLICEBITMAPUSERINFO;
L_INT L_EXPORT EXT_CALLBACK ExampleSliceCB(pBITMAPHANDLE pBitmap, LPRECT lpSliceRect, L_INT nAngle, L_VOID * pUserData)
{
pSLICEBITMAPUSERINFO pSlicesUserInfo;
L_CHAR szDirectory[L_MAXPATH];
L_CHAR S[30];
L_INT nRet;
pSlicesUserInfo = (pSLICEBITMAPUSERINFO)pUserData;
lstrcpy(szDirectory, pSlicesUserInfo->SlicesFolder);
strcat(szDirectory, TEXT("\\"));
wsprintf(S,TEXT("%d.bmp"), (pSlicesUserInfo->SlicesCount));
strcat(szDirectory, S);
nRet = L_SAVEFILE(szDirectory, pBitmap, FILE_BMP, 24, 0, SAVEFILE_FIXEDPALETTE, NULL, NULL, NULL);
if(nRet == SUCCESS)
{
pSlicesUserInfo->SlicesCount++;
L_FREEBITMAP(pBitmap);
GlobalFree(pBitmap);
}
return SUCCESS;
}
void CDemoView::OnExampleSlicebitmap()
{
SLICEBITMAPOPTIONS Options;
SLICEBITMAPUSERINFO UserData;
L_INT nRet;
L_CHAR S[30] = TEXT("");
L_CHAR Message[512] = TEXT("");
L_CHAR *SlicesFolder = "e:\\slices";
Options.uStructSize = sizeof(SLICEBITMAPOPTIONS);
// Deskew the sliced image, the deskew angle is located between -5 and 5 degrees
Options.uFlags = SLC_DESKEW|SLC_DSKW_LINEAR|SLC_CUTSLICES;
Options.uMaxDeskewAngle = 500;
Options.crFill = RGB(0,0,0);
memcpy(UserData.SlicesFolder, SlicesFolder, L_MAXPATH);
UserData.SlicesCount = 0;
nRet = L_SLICEBITMAP(m_LAniWnd.GetHandle(), &Options, NULL, ExampleSliceCB, (L_VOID *)(&UserData));
if(nRet == SUCCESS)
{
lstrcpy(Message, TEXT("The number of sliced images is "));
wsprintf(S, TEXT("%d"), (UserData.SlicesCount));
strcat(Message, S );
MessageBox( Message, TEXT("SliceBitmap Example"), MB_OK);
}
}
This function is designed to extract the individual slices from radiographic scanned film. The image below shows an example of these radiographic images before and after applying the LBitmap::Slice function where we use the output data to draw a white line around each separate slice.
Film Before Function Is Called
Film After Function Is Called
To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.
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 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.
Win32, x64.
class LSliceBitmap : public LBitmap
{
public:
LSliceBitmap();
~LSliceBitmap();
virtual L_INT SliceCallBack(LBitmapBase &Bitmap,
LPRECT lpSliceRect,
L_INT nAngle);
};
LSliceBitmap::LSliceBitmap()
{
}
LSliceBitmap::~LSliceBitmap()
{
}
L_INT LSliceBitmap::SliceCallBack(LBitmapBase &Bitmap, LPRECT lpSliceRect, L_INT nAngle)
{
UNREFERENCED_PARAMETER(nAngle);
UNREFERENCED_PARAMETER(lpSliceRect);
static L_INT nCount = 1 ;
L_TCHAR szFileName[L_MAXPATH];
L_INT nRet;
LBitmap UserBitmap;
wsprintf(szFileName,MAKE_IMAGE_PATH(TEXT("Slice%d.bmp")), (nCount));
UserBitmap.SetHandle(Bitmap.GetHandle());
nRet = UserBitmap.Save(szFileName, FILE_BMP, 24, 2, 0);
if(nRet == SUCCESS)
{
(nCount)++;
UserBitmap.Free();
}
return SUCCESS;
}
L_INT LBitmap__SliceExample(LBitmap *pBitmap)
{
int nRet = 0;
LSliceBitmap UserBitmap;
SLICEBITMAPOPTIONS Options;
memset(&Options , 0, sizeof(Options));
Options.uStructSize = sizeof(Options);
Options.uMaxDeskewAngle = 500;
Options.crFill = RGB(0,0,0);
Options.uFlags = SLC_DESKEW | SLC_DSKW_LINEAR | SLC_CUTSLICES ;
UserBitmap.EnableCallBack(TRUE);
UserBitmap.SetHandle(pBitmap->GetHandle()) ;
nRet = UserBitmap.Slice(&Options, NULL);
pBitmap->SetHandle(UserBitmap.GetHandle()) ;
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document