发布时间 : 星期三 文章SLIC超像素分割算法和目前超像素算法的比较代码实现更新完毕开始阅读cc403f8fa6c30c2259019ee9
}
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()
}
// with the ENM_CHANGE flag ORed into the mask.
UpdateData(TRUE);//FALSE to set data, TRUE to retrieve data
void CSLICSuperpixelsDlg::OnEnChangeEditCompactness() { }
// If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework.
void CSLICSuperpixelsDlg::OnPaint() {
} else {
CDialog::OnPaint(); // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
// Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2;
SendMessage(WM_ICONERASEBKGND, reinterpret_cast
CPaintDC dc(this); // device context for painting UpdateData(TRUE);//FALSE to set data, TRUE to retrieve data // 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() // with the ENM_CHANGE flag ORed into the mask.
}
}
// The system calls this function to obtain the cursor to display while the user drags // the minimized window.
HCURSOR CSLICSuperpixelsDlg::OnQueryDragIcon() { }
//================================================================================= /// GetPictures ///
/// This function collects all the pictures the user chooses into a vector. //================================================================================= void CSLICSuperpixelsDlg::GetPictures(vector
//if(cfd.DoModal() == IDOK) if( bResult ) { }
POSITION pos = cfd.GetStartPosition(); while (pos) { }
CString imgFile = cfd.GetNextPathName(pos); PictureHandler ph;
string name = ph.Wide2Narrow(imgFile.GetString()); picvec.push_back(name);
BOOL bResult = cfd.DoModal() == IDOK ? TRUE : FALSE; strFileNames.ReleaseBuffer();
//cfd.PostMessage(WM_COMMAND, 40964, NULL);
CString strFileNames;
cfd.m_ofn.lpstrFile = strFileNames.GetBuffer(2048); cfd.m_ofn.nMaxFile = 2048;
CFileDialog cfd(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,L\,NULL); cfd.m_ofn.Flags |= OFN_ALLOWMULTISELECT; return static_cast
}
else return;
//=========================================================================== /// BrowseForFolder ///
/// The main function
//=========================================================================== bool CSLICSuperpixelsDlg::BrowseForFolder(string& folderpath) { }
//=========================================================================== /// DoSupervoxelVideoSegmentation ///
/// Supervoxel segmentation demo
//=========================================================================== void CSLICSuperpixelsDlg::DoSupervoxelVideoSegmentation() {
const int width = 7; TCHAR buffer[_MAX_PATH];
if(::SHGetPathFromIDList(pIDL, buffer) == 0) return false;
PictureHandler pichand;
folderpath = pichand.Wide2Narrow(buffer); folderpath.append(\); return true;
LPITEMIDLIST pIDL = ::SHBrowseForFolder(&bi); if(pIDL == NULL) return false;
bi.hwndOwner = m_hWnd;
bi.lpszTitle = L\; BROWSEINFO bi;
memset(&bi, 0, sizeof(bi)); IMalloc* pMalloc = 0;
if(::SHGetMalloc(&pMalloc) != NOERROR) return false;