Extracts individual slices from radiographic scanned film.
#include "ltwrappr.h"
L_INT LBitmapBase::Slice(pOptions, pnDeskewAngle)
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.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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 LBitmapBase::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 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.
Win32, x64.
class LUserBitmapWindow : public LBitmapWindow
{
public:
L_INT m_uSlicesCount;
virtual L_INT SliceCallBack(LBitmapBase * pBitmap, LPRECT lpSliceRect, L_INT nAngle);
};
void SliceExample(CWnd * pWnd)
{
LUserBitmapWindow BitmapWindow;
SLICEBITMAPOPTIONS Options;
L_INT nRet;
L_TCHAR S[30] = L"";
L_TCHAR Message[512] = L"";
LBase::LoadLibraries (LT_ALL_LEADLIB);
nRet = BitmapWindow.SetWndHandle (pWnd->GetSafeHwnd());
BitmapWindow.EnableCallBack (TRUE);
nRet = BitmapWindow.Load (TEXT("c:\\parrots.jpg"));
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);
nRet = BitmapWindow.Slice(&Options, NULL);
if(nRet == SUCCESS)
{
lstrcpy(Message, L"The number of sliced image is");
wsprintf(S, L"%d", BitmapWindow.m_uSlicesCount);
lstrcat(Message, S );
MessageBox(pWnd->GetSafeHwnd(), Message, L"SliceBitmap Example", MB_OK);
}
BitmapWindow.SetWndHandle (NULL);
}
L_INT LUserBitmapWindow::SliceCallBack(LBitmapBase * pBitmap,
LPRECT lpSliceRect,
L_INT nAngle)
{
UNREFERENCED_PARAMETER(nAngle);
UNREFERENCED_PARAMETER(lpSliceRect);
L_TCHAR szDirectory[L_MAXPATH];
L_TCHAR S[30];
L_INT nRet;
lstrcpy(szDirectory, TEXT("c:\\SliceTmp"));
lstrcat(szDirectory, TEXT("\\"));
wsprintf(S, TEXT("%d.bmp"), m_uSlicesCount);
lstrcat(szDirectory, S);
nRet = Save(szDirectory, FILE_BMP, 24, 0, 0);
if(nRet == SUCCESS)
{
m_uSlicesCount ++;
pBitmap->Free ();
}
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