/// the input is greyscale with values ranging from 0-100, then a compactness /// value of 20.0 would give good results. A greater value will make the /// supervoxels more compact while a smaller value would make them more uneven. //=========================================================================== void SLIC::DoSupervoxelSegmentation(
unsigned int**& const int& const int& const int& int**& int&
ubuffvec, width, height, depth, klabels, supervoxelsize,
numlabels,
const int& {
const double& compactness)
//--------------------------------------------------------- const int STEP = 0.5 + pow(double(supervoxelsize),1.0/3.0); //---------------------------------------------------------
//-------------------------------------------------- m_width = width; m_height = height; m_depth = depth;
int sz = m_width*m_height;
//-------------------------------------------------- m_lvecvec = new double*[depth]; m_avecvec = new double*[depth]; m_bvecvec = new double*[depth]; for( int d = 0; d < depth; d++ ) {
m_lvecvec[d] = new double[sz]; m_avecvec[d] = new double[sz]; m_bvecvec[d] = new double[sz]; vector
//klabels = new int*[depth];
//klabels[d] = new int[sz];
}
}
for( int s = 0; s < sz; s++ ) { }
klabels[d][s] = -1;
DoRGBtoLABConversion(ubuffvec, m_lvecvec, m_avecvec, m_bvecvec);
GetKValues_LABXYZ(kseedsl, kseedsa, kseedsb, kseedsx, kseedsy, kseedsz, STEP);
PerformSupervoxelSLIC(kseedsl, kseedsa, kseedsb, kseedsx, kseedsy, kseedsz, klabels, STEP,
compactness);
EnforceSupervoxelLabelConnectivity(klabels, width, height, depth, numlabels, STEP);
SLICSuperpixels.cpp
// SLICSuperpixels.cpp : Defines the class behaviors for the application. //
#include \
#include \ #include \
#ifdef _DEBUG
#define new DEBUG_NEW #endif
// CSLICSuperpixelsApp
BEGIN_MESSAGE_MAP(CSLICSuperpixelsApp, CWinAppEx)
// CSLICSuperpixelsApp construction
ON_COMMAND(ID_HELP, &CWinApp::OnHelp) END_MESSAGE_MAP()
CSLICSuperpixelsApp::CSLICSuperpixelsApp() { }
// The one and only CSLICSuperpixelsApp object
CSLICSuperpixelsApp theApp;
// CSLICSuperpixelsApp initialization
BOOL CSLICSuperpixelsApp::InitInstance() {
CSLICSuperpixelsDlg dlg; m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { }
else if (nResponse == IDCANCEL) { }
// TODO: Place code here to handle when the dialog is // dismissed with Cancel
// TODO: Place code here to handle when the dialog is // dismissed with OK // Standard initialization
// If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization
SetRegistryKey(_T(\)); CWinAppEx::InitInstance();
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE;
SLICSuperpixelsDlg.cpp
// SLICSuperpixelsDlg.cpp : implementation file //
#include \
#include \ #include \ #include \ #include \
#ifdef _DEBUG
#define new DEBUG_NEW #endif
// CSLICSuperpixelsDlg dialog
CSLICSuperpixelsDlg::CSLICSuperpixelsDlg(CWnd* pParent /*=NULL*/) { }
void CSLICSuperpixelsDlg::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); : CDialog(CSLICSuperpixelsDlg::IDD, pParent) , m_spcount(0) , m_compactness(0)
}
DDX_Text(pDX, IDC_EDIT_SPCOUNT, m_spcount); DDV_MinMaxInt(pDX, m_spcount, 1, 10000000);
DDX_Text(pDX, IDC_EDIT_COMPACTNESS, m_compactness); DDV_MinMaxDouble(pDX, m_compactness, 1.0, 80.0);
BEGIN_MESSAGE_MAP(CSLICSuperpixelsDlg, CDialog)
// CSLICSuperpixelsDlg message handlers
BOOL CSLICSuperpixelsDlg::OnInitDialog() { }
void CSLICSuperpixelsDlg::OnEnChangeEditSpcount() {
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask()
return TRUE; // return TRUE unless you set the focus to a control // TODO: Add extra initialization here m_spcount = 200; m_compactness = 10.0;
UpdateData(FALSE);//FALSE to set data, TRUE to retrieve data
// Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE);
// Set big icon
SetIcon(m_hIcon, FALSE);
// Set small icon
CDialog::OnInitDialog(); ON_WM_PAINT()
ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_BUTTON_CREATESUPERPIXELS,
ON_EN_CHANGE(IDC_EDIT_SPCOUNT, &CSLICSuperpixelsDlg::OnEnChangeEditSpcount)
ON_EN_CHANGE(IDC_EDIT_COMPACTNESS, &CSLICSuperpixelsDlg::OnEnChangeEditCompactness)
&CSLICSuperpixelsDlg::OnBnClickedButtonCreatesuperpixels)
END_MESSAGE_MAP()
搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新IT计算机SLIC超像素分割算法和目前超像素算法的比较代码实现 - 图文 (10)全文阅读和word下载服务。
相关推荐: