mirror of https://github.com/CGAL/cgal
Algorithm:
Segment image then detect vertices of borders. Triangulate these vertices using a new class Gyroviz_border_points_dt2.h The triangulation of these points is useful to dissociate the constraints quality of the segmentation threshold value. TODO : Launch the Segmentation + CDT2 on a sequence of *.BMP and *.PNT images.
This commit is contained in:
parent
d45bf6c1c0
commit
5e5fcc83d0
|
|
@ -4170,12 +4170,16 @@ Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/Gyroviz.rc -text
|
|||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/Gyroviz.reg -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/GyrovizDoc_3.cpp -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/GyrovizDoc_3.h -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/GyrovizDoc_4.cpp -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/GyrovizDoc_4.h -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/GyrovizView_3.cpp -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/GyrovizView_3.h -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/Gyroviz_border_points_dt2.h -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/Gyroviz_vc71.sln -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/Gyroviz_vc71.vcproj -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/Gyroviz_vc80.sln -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/Gyroviz_vc80.vcproj -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/Gyroviz_vertex_segment_2.h -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/MainFrm.cpp -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/MainFrm.h -text
|
||||
Surface_reconstruction_3/demo/Surface_reconstruction_3/gyroviz/data/Isidor_50.pwc -text
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include "MainFrm.h"
|
||||
|
||||
#include "ChildFrm.h"
|
||||
#include "GyrovizDoc_4.h"
|
||||
#include "GyrovizView_4.h"
|
||||
#include "GyrovizDoc_3.h"
|
||||
#include "GyrovizView_3.h"
|
||||
#include "GyrovizDoc_2.h"
|
||||
|
|
@ -64,15 +66,15 @@ BOOL CGyrovizApp::InitInstance()
|
|||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views
|
||||
CMultiDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CMultiDocTemplate(IDR_GyrovizTYPE_3,
|
||||
CMultiDocTemplate* pDocTemplate3;
|
||||
pDocTemplate3 = new CMultiDocTemplate(IDR_GyrovizTYPE_3,
|
||||
RUNTIME_CLASS(CGyrovizDoc_3),
|
||||
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
|
||||
RUNTIME_CLASS(CGyrovizView_3));
|
||||
if (!pDocTemplate)
|
||||
if (!pDocTemplate3)
|
||||
return FALSE;
|
||||
AddDocTemplate(pDocTemplate);
|
||||
//
|
||||
AddDocTemplate(pDocTemplate3);
|
||||
//
|
||||
CMultiDocTemplate* pDocTemplate2;
|
||||
pDocTemplate2 = new CMultiDocTemplate(IDR_GyrovizTYPE_2,
|
||||
RUNTIME_CLASS(CGyrovizDoc_2),
|
||||
|
|
@ -81,6 +83,15 @@ BOOL CGyrovizApp::InitInstance()
|
|||
if (!pDocTemplate2)
|
||||
return FALSE;
|
||||
AddDocTemplate(pDocTemplate2);
|
||||
//
|
||||
CMultiDocTemplate* pDocTemplate4;
|
||||
pDocTemplate4 = new CMultiDocTemplate(IDR_GyrovizTYPE_4,
|
||||
RUNTIME_CLASS(CGyrovizDoc_4),
|
||||
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
|
||||
RUNTIME_CLASS(CGyrovizView_4));
|
||||
if (!pDocTemplate4)
|
||||
return FALSE;
|
||||
AddDocTemplate(pDocTemplate4);
|
||||
|
||||
// create main MDI Frame window
|
||||
CMainFrame* pMainFrame = new CMainFrame;
|
||||
|
|
|
|||
|
|
@ -205,6 +205,62 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDR_GyrovizTYPE_4 MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN
|
||||
MENUITEM "&Close", ID_FILE_CLOSE
|
||||
MENUITEM "Save input point set &as...\tCtrl+S", ID_FILE_SAVE_AS
|
||||
MENUITEM "Save reconstructed surface as...", ID_FILE_SAVE_SURFACE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Recent File", ID_FILE_MRU_FILE1
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT
|
||||
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
|
||||
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Options...\tO", ID_EDIT_OPTIONS
|
||||
END
|
||||
MENUITEM "&Algorithms", ID_ALGORITHMS
|
||||
POPUP "&Render"
|
||||
BEGIN
|
||||
MENUITEM "Vertices\tG", ID_RENDER_POINTS
|
||||
MENUITEM "Border Vertices\tB", ID_RENDER_BORDERVERTICES32845
|
||||
MENUITEM "Edges\tD", ID_RENDER_DELAUNAYEDGES
|
||||
MENUITEM "Triangles\tT", ID_RENDER_TRIANGLES
|
||||
MENUITEM "Rays\tR", ID_RENDERCOFF_RAYS
|
||||
MENUITEM "Inside Tetrahedrons\tI", ID_RENDERCOFF_INSIDE
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "Arcball"
|
||||
BEGIN
|
||||
MENUITEM "Reset", ID_ARCBALL_RESET
|
||||
MENUITEM "View sphere", ID_RENDER_ARCBALL
|
||||
END
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
|
||||
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
|
||||
END
|
||||
POPUP "&Window"
|
||||
BEGIN
|
||||
MENUITEM "&New Window", ID_WINDOW_NEW
|
||||
MENUITEM "&Cascade", ID_WINDOW_CASCADE
|
||||
MENUITEM "&Tile", ID_WINDOW_TILE_HORZ
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About Gyroviz...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
@ -217,7 +273,7 @@ BEGIN
|
|||
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
|
||||
"X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
|
||||
"O", ID_EDIT_OPTIONS, VIRTKEY, NOINVERT
|
||||
"O", ID_EDIT_OPTIONS, VIRTKEY, ALT, NOINVERT
|
||||
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
|
||||
|
|
@ -231,6 +287,7 @@ BEGIN
|
|||
"M", ID_RECONSTRUCTION_SURFACEMESHING, VIRTKEY, NOINVERT
|
||||
"A", ID_RENDER_ARCBALL, VIRTKEY, CONTROL, NOINVERT
|
||||
"B", ID_RENDER_BORDERVERTICES, VIRTKEY, NOINVERT
|
||||
"C", ID_RENDER_CONSTRAINTS, VIRTKEY, ALT, NOINVERT
|
||||
"C", ID_RENDER_CONTOUR, VIRTKEY, NOINVERT
|
||||
"D", ID_RENDER_DELAUNAYEDGES, VIRTKEY, NOINVERT
|
||||
"F", ID_RENDER_FILTERED, VIRTKEY, NOINVERT
|
||||
|
|
@ -246,7 +303,7 @@ BEGIN
|
|||
VK_OEM_MINUS, ID_RENDER_ZOOMOUT, VIRTKEY, NOINVERT
|
||||
"I", ID_RENDERCOFF_INSIDE, VIRTKEY, NOINVERT
|
||||
"R", ID_RENDERCOFF_RAYS, VIRTKEY, NOINVERT
|
||||
"C", ID_RENDER_CONSTRAINTS, VIRTKEY, ALT, NOINVERT
|
||||
"O", ID_RENDER_ORIGINALIMAGE, VIRTKEY, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
|
|
@ -339,6 +396,7 @@ BEGIN
|
|||
IDS_MESSAGE2 "------------------------"
|
||||
IDS_MESSAGE3 "---------------------"
|
||||
IDR_GyrovizTYPE_2 "\nGyroviz\nGyroviz\nImage Files (*.ppm)\n.ppm\nGyroviz.Document\nGyroviz.Document"
|
||||
IDR_GyrovizTYPE_4 "\nGyroviz\nGyroviz\nImage Sequences (*.bmp)\n.bmp\nGyroviz.Document\nGyroviz.Document"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
|
@ -496,6 +554,17 @@ BEGIN
|
|||
EDITTEXT IDC_EDIT_POINT_SIZE,96,28,30,12,ES_AUTOHSCROLL
|
||||
END
|
||||
|
||||
IDD_DIALOG_OPTIONS_4 DIALOGEX 0, 0, 242, 110
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Options"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,171,77,50,14
|
||||
PUSHBUTTON "Annuler",IDCANCEL,117,77,50,14
|
||||
LTEXT "OpenGL Point Size",IDC_STATIC,24,29,52,8
|
||||
EDITTEXT IDC_EDIT_POINT_SIZE,96,28,30,12,ES_AUTOHSCROLL
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
@ -520,6 +589,14 @@ BEGIN
|
|||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 103
|
||||
END
|
||||
|
||||
IDD_DIALOG_OPTIONS_4, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 235
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 103
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ BOOL CGyrovizDoc_2::OnOpenDocument(LPCTSTR lpszPathName)
|
|||
m_cimg_filt_image = gauss3(m_cimg_gray_image);
|
||||
m_filtered_image = cimg_image_multiplexer_char(m_cimg_filt_image);
|
||||
|
||||
m_cimg_seg_image = grad_freiChen(m_cimg_filt_image,30); // Edge detection on filtered image
|
||||
m_cimg_seg_image = grad_freiChen(m_cimg_filt_image,15); // Edge detection on filtered image def : 30
|
||||
m_segmented_image = cimg_image_multiplexer_char(m_cimg_seg_image);
|
||||
}
|
||||
else
|
||||
|
|
@ -214,7 +214,7 @@ BOOL CGyrovizDoc_2::OnOpenDocument(LPCTSTR lpszPathName)
|
|||
AfxMessageBox("Unable to open file");
|
||||
return FALSE;
|
||||
}
|
||||
m_gyroviz_dt.nw_add_constraints(m_cimg_seg_image, 1);
|
||||
m_gyroviz_dt.nw_add_constraints(m_cimg_seg_image, 5);
|
||||
status_message("Constrained Delaunay triangulation (%lf s)",duration(init));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ IMPLEMENT_DYNCREATE(CGyrovizDoc_3, CDocument)
|
|||
|
||||
BEGIN_MESSAGE_MAP(CGyrovizDoc_3, CDocument)
|
||||
ON_COMMAND(ID_EDIT_OPTIONS, OnEditOptions)
|
||||
ON_COMMAND(ID_FILE_SAVE_SURFACE, OnFileSaveSurface)
|
||||
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_SURFACE, OnUpdateFileSaveSurface)
|
||||
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
|
||||
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_AS, OnUpdateFileSaveAs)
|
||||
ON_COMMAND(ID_FILE_SAVE_SURFACE, OnFileSaveSurface)
|
||||
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_SURFACE, OnUpdateFileSaveSurface)
|
||||
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
|
||||
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_AS, OnUpdateFileSaveAs)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
|
|
@ -67,13 +67,13 @@ BOOL CGyrovizDoc_3::OnOpenDocument(LPCTSTR lpszPathName)
|
|||
CString extension = lpszPathName;
|
||||
extension = extension.Right(4);
|
||||
extension.MakeLower();
|
||||
|
||||
|
||||
// set current path
|
||||
CString path = lpszPathName;
|
||||
path = path.Left(path.ReverseFind('\\'));
|
||||
SetCurrentDirectory(path);
|
||||
|
||||
// if .pnt extension
|
||||
// if .pnt extension
|
||||
if(extension.CompareNoCase(".pnt") == 0)
|
||||
{
|
||||
double init = clock();
|
||||
|
|
@ -82,13 +82,15 @@ BOOL CGyrovizDoc_3::OnOpenDocument(LPCTSTR lpszPathName)
|
|||
AfxMessageBox("Unable to open file");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//m_gyroviz_dt.nw_add_constraints(m_cimg_seg_image, 1); // for cdt2
|
||||
status_message("Delaunay triangulation (%lf s)",duration(init));
|
||||
}
|
||||
|
||||
|
||||
// if .pwc extension
|
||||
else if (extension.CompareNoCase(".pwc") == 0)
|
||||
{
|
||||
double init = clock();
|
||||
double init = clock();
|
||||
if(!m_gyroviz_dt3.read_pwc((char *)lpszPathName))
|
||||
{
|
||||
AfxMessageBox("Unable to open file");
|
||||
|
|
@ -96,16 +98,16 @@ BOOL CGyrovizDoc_3::OnOpenDocument(LPCTSTR lpszPathName)
|
|||
}
|
||||
status_message("3D Delaunay triangulation (%lf s)",duration(init));
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
else
|
||||
{
|
||||
AfxMessageBox("File format not supported");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
update_status();
|
||||
update_status();
|
||||
UpdateAllViews(NULL);
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Save input point set as... callback
|
||||
|
|
@ -117,9 +119,9 @@ void CGyrovizDoc_3::OnFileSaveAs()
|
|||
// to avoid jeopardizing the input file.
|
||||
void CGyrovizDoc_3::OnUpdateFileSaveAs(CCmdUI *pCmdUI)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
pCmdUI->Enable(!m_gyroviz_solved);
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
// Save reconstructed surface as... callback
|
||||
|
|
@ -130,9 +132,9 @@ void CGyrovizDoc_3::OnFileSaveSurface()
|
|||
// Enable "Save reconstructed surface as..." if surface is computed
|
||||
void CGyrovizDoc_3::OnUpdateFileSaveSurface(CCmdUI *pCmdUI)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
pCmdUI->Enable(m_surface_mesher_dt.number_of_vertices() > 0);
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
// Update the number of vertices and faces in the status bar
|
||||
|
|
@ -144,7 +146,7 @@ void CGyrovizDoc_3::update_status()
|
|||
CStatusBar* pStatus =
|
||||
(CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(
|
||||
AFX_IDW_STATUS_BAR);
|
||||
|
||||
|
||||
if(pStatus != NULL)
|
||||
{
|
||||
CString vertices;
|
||||
|
|
@ -158,7 +160,7 @@ void CGyrovizDoc_3::update_status()
|
|||
pStatus->SetPaneText(2,faces);
|
||||
pStatus->UpdateWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set user message in status bar
|
||||
|
|
@ -171,19 +173,19 @@ void CGyrovizDoc_3::status_message(char* fmt,...)
|
|||
CStatusBar* pStatus =
|
||||
(CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(
|
||||
AFX_IDW_STATUS_BAR);
|
||||
|
||||
|
||||
// fill buffer
|
||||
va_list argptr;
|
||||
va_start(argptr,fmt);
|
||||
vsprintf(buffer,fmt,argptr);
|
||||
va_end(argptr);
|
||||
|
||||
|
||||
if(pStatus != NULL)
|
||||
{
|
||||
pStatus->SetPaneText(0,buffer);
|
||||
pStatus->UpdateWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -201,5 +203,5 @@ void CGyrovizDoc_3::OnEditOptions()
|
|||
|
||||
double CGyrovizDoc_3::duration(const double time_init)
|
||||
{
|
||||
return (clock() - time_init)/CLOCKS_PER_SEC;
|
||||
return (clock() - time_init)/CLOCKS_PER_SEC;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,237 @@
|
|||
// GyrovizDoc_4.cpp : implementation of the CGyrovizDoc_4 class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GyrovizDoc_4.h"
|
||||
#include "MainFrm.h"
|
||||
#include "DialogOptions_4.h"
|
||||
|
||||
using namespace cimg_library;
|
||||
|
||||
#include "Gyroviz_segmentation2.h"
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
// CGyrovizDoc_4
|
||||
|
||||
IMPLEMENT_DYNCREATE(CGyrovizDoc_4, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CGyrovizDoc_4, CDocument)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CGyrovizDoc_4 construction/destruction
|
||||
|
||||
CGyrovizDoc_4::CGyrovizDoc_4()
|
||||
{
|
||||
}
|
||||
|
||||
CGyrovizDoc_4::~CGyrovizDoc_4()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CGyrovizDoc_4::OnNewDocument()
|
||||
{
|
||||
if (!CDocument::OnNewDocument())
|
||||
return FALSE;
|
||||
// TODO: add reinitialization code here
|
||||
// (SDI documents will reuse this document)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// CGyrovizDoc_4 serialization
|
||||
|
||||
void CGyrovizDoc_4::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
// TODO: add storing code here
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: add loading code here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CGyrovizDoc_4 diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CGyrovizDoc_4::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void CGyrovizDoc_4::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
// CGyrovizDoc_4 commands
|
||||
|
||||
|
||||
// Update the number of vertices and faces in the status bar
|
||||
void CGyrovizDoc_4::update_status()
|
||||
{
|
||||
CWinApp *pApp = AfxGetApp();
|
||||
if(pApp->m_pMainWnd != NULL)
|
||||
{
|
||||
CStatusBar* pStatus =
|
||||
(CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(
|
||||
AFX_IDW_STATUS_BAR);
|
||||
|
||||
if(pStatus != NULL)
|
||||
{
|
||||
//CString vertices;
|
||||
//vertices.Format("%d vertices",m_gyroviz_dt.number_of_vertices());
|
||||
|
||||
//CString faces;
|
||||
//faces.Format("%d faces",m_gyroviz_dt.number_of_faces());
|
||||
|
||||
//// Update status bar
|
||||
//pStatus->SetPaneText(1,vertices);
|
||||
//pStatus->SetPaneText(2,faces);
|
||||
//pStatus->UpdateWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// User message in status bar
|
||||
void CGyrovizDoc_4::status_message(char* fmt,...)
|
||||
{
|
||||
CWinApp *pApp = AfxGetApp();
|
||||
if(pApp->m_pMainWnd != NULL)
|
||||
{
|
||||
char buffer[256];
|
||||
CStatusBar* pStatus =
|
||||
(CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(
|
||||
AFX_IDW_STATUS_BAR);
|
||||
|
||||
// fill buffer
|
||||
va_list argptr;
|
||||
va_start(argptr,fmt);
|
||||
vsprintf(buffer,fmt,argptr);
|
||||
va_end(argptr);
|
||||
|
||||
if(pStatus != NULL)
|
||||
{
|
||||
pStatus->SetPaneText(0,buffer);
|
||||
pStatus->UpdateWindow();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
BOOL CGyrovizDoc_4::OnSaveDocument(LPCTSTR lpszPathName)
|
||||
{
|
||||
// save pslg to a file
|
||||
//return m_pslg.save((char *)lpszPathName);
|
||||
return CDocument::OnSaveDocument(lpszPathName);
|
||||
}
|
||||
|
||||
|
||||
BOOL CGyrovizDoc_4::OnOpenDocument(LPCTSTR lpszPathName)
|
||||
{
|
||||
//
|
||||
// Read bitmap image
|
||||
//
|
||||
|
||||
if (!CDocument::OnOpenDocument(lpszPathName))
|
||||
return FALSE;
|
||||
|
||||
// get extension
|
||||
CString file = lpszPathName;
|
||||
CString extension = lpszPathName;
|
||||
extension = extension.Right(4);
|
||||
extension.MakeLower();
|
||||
|
||||
// set current path
|
||||
// path "c:\path\file.wrl" -> c:\path
|
||||
CString path = lpszPathName;
|
||||
path = path.Left(path.ReverseFind('\\'));
|
||||
SetCurrentDirectory(path);
|
||||
|
||||
if(extension == ".bmp")
|
||||
{// read bmp format image
|
||||
m_cimg_interm_image = CImg<unsigned char>((char *)lpszPathName);
|
||||
m_original_image = cimg_image_multiplexer_char(m_cimg_interm_image);
|
||||
|
||||
m_cimg_gray_image = to_grayscale(m_cimg_interm_image);
|
||||
m_grayscaled_image = cimg_image_multiplexer_char(m_cimg_gray_image);
|
||||
|
||||
m_cimg_filt_image = gauss3(m_cimg_gray_image);
|
||||
m_filtered_image = cimg_image_multiplexer_char(m_cimg_filt_image);
|
||||
|
||||
m_cimg_seg_image = grad_freiChen(m_cimg_filt_image,15); // Edge detection on filtered image def : 30
|
||||
m_segmented_image = cimg_image_multiplexer_char(m_cimg_seg_image);
|
||||
}
|
||||
else
|
||||
{
|
||||
AfxMessageBox("File format not supported");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Read corresponding Voodoo 2D feature file (.pnt)
|
||||
//
|
||||
|
||||
// file filters
|
||||
static char szFilter[] = "Voodoo 2D Feature Files (*.pnt)|*.pnt|All Files (*.*)|*.*||";
|
||||
|
||||
// create the Open dialog
|
||||
CFileDialog dlgOpen(true, "pnt", NULL,
|
||||
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST, szFilter, AfxGetMainWnd());
|
||||
|
||||
// dialog title
|
||||
dlgOpen.m_ofn.lpstrTitle = "Select corresponding Voodoo 2D feature file";
|
||||
|
||||
// show the dialog
|
||||
if (dlgOpen.DoModal() == IDOK)
|
||||
{
|
||||
// get extension
|
||||
CString file = dlgOpen.m_ofn.lpstrFile;
|
||||
CString extension = dlgOpen.m_ofn.lpstrFile;
|
||||
extension = extension.Right(4);
|
||||
extension.MakeLower();
|
||||
|
||||
// set current path
|
||||
CString path = dlgOpen.m_ofn.lpstrFile;
|
||||
path = path.Left(path.ReverseFind('\\'));
|
||||
SetCurrentDirectory(path);
|
||||
|
||||
// if .pnt extension
|
||||
if(extension.CompareNoCase(".pnt") == 0)
|
||||
{
|
||||
double init = clock();
|
||||
if(!m_gyroviz_dt.read_pnt((char *)dlgOpen.m_ofn.lpstrFile))
|
||||
{
|
||||
AfxMessageBox("Unable to open file");
|
||||
return FALSE;
|
||||
}
|
||||
m_gyroviz_dt.nw_add_constraints(m_cimg_seg_image, 5);
|
||||
status_message("Constrained Delaunay triangulation (%lf s)",duration(init));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
AfxMessageBox("File format not supported");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
update_status();
|
||||
UpdateAllViews(NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
double CGyrovizDoc_4::duration(const double time_init)
|
||||
{
|
||||
return (clock() - time_init)/CLOCKS_PER_SEC;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
// GyrovizDoc_4.h : interface of the CGyrovizDoc_4 class
|
||||
#pragma once
|
||||
|
||||
// STL
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
|
||||
// CGAL
|
||||
#include "GyrovizKernel.h"
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||
|
||||
// CImg
|
||||
#include <CImg.h>
|
||||
using namespace cimg_library;
|
||||
|
||||
// This demo
|
||||
//#include "Gyroviz_dt2.h"
|
||||
#include "Gyroviz_cdt2.h"
|
||||
|
||||
// Gyroviz's Delaunay triangulation 2-3
|
||||
//typedef CGAL::Triangulation_vertex_base_with_info_2<Gyroviz_info_for_dt2,K> Vb;
|
||||
//typedef CGAL::Triangulation_face_base_2<K> Fb;
|
||||
//typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
|
||||
//typedef Gyroviz_dt2<K,Tds> Dt2;
|
||||
//typedef Dt2::Face_handle Face_handle;
|
||||
//typedef Dt2::Finite_faces_iterator Finite_faces_iterator;
|
||||
//typedef Dt2::Finite_edges_iterator Finite_edges_iterator;
|
||||
//typedef Dt2::Finite_vertices_iterator Finite_vertices_iterator;
|
||||
typedef CGAL::Triangulation_vertex_base_with_info_2<Gyroviz_info_for_cdt2,K> CVb;
|
||||
typedef CGAL::Constrained_triangulation_face_base_2<K> CFb;
|
||||
typedef CGAL::Triangulation_data_structure_2<CVb,CFb> CTds;
|
||||
typedef CGAL::Exact_predicates_tag Itag;
|
||||
typedef Gyroviz_cdt2<K,CTds, Itag> CDt2;
|
||||
|
||||
|
||||
|
||||
|
||||
class CGyrovizDoc_4 : public CDocument
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CGyrovizDoc_4();
|
||||
DECLARE_DYNCREATE(CGyrovizDoc_4)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
CImg <unsigned char> m_cimg_interm_image;
|
||||
CImg<unsigned char> m_cimg_gray_image;
|
||||
CImg<unsigned char> m_cimg_filt_image;
|
||||
CImg<unsigned char> m_cimg_seg_image;
|
||||
|
||||
unsigned char* m_original_image;
|
||||
unsigned char* m_grayscaled_image;
|
||||
unsigned char* m_filtered_image;
|
||||
unsigned char* m_segmented_image;
|
||||
|
||||
|
||||
// Triangulation
|
||||
//Dt2 m_gyroviz_dt; // The Gyroviz equation is solved on the vertices of m_gyroviz_dt
|
||||
CDt2 m_gyroviz_dt; // The Gyroviz equation is solved on the vertices of m_gyroviz_dt
|
||||
|
||||
// Public methods
|
||||
public:
|
||||
|
||||
// Get triangulation.
|
||||
//Dt2& get_dt2()
|
||||
//{
|
||||
// return m_gyroviz_dt;
|
||||
//}
|
||||
//const Dt2& get_dt2() const
|
||||
//{
|
||||
// return m_gyroviz_dt;
|
||||
//}
|
||||
|
||||
CDt2& get_cdt2()
|
||||
{
|
||||
return m_gyroviz_dt;
|
||||
}
|
||||
const CDt2& get_cdt2() const
|
||||
{
|
||||
return m_gyroviz_dt;
|
||||
}
|
||||
|
||||
// Private methods
|
||||
private:
|
||||
|
||||
// misc status stuff
|
||||
void update_status();
|
||||
void status_message(char* fmt,...);
|
||||
double duration(const double time_init);
|
||||
|
||||
// Overrides
|
||||
public:
|
||||
virtual BOOL OnNewDocument();
|
||||
virtual void Serialize(CArchive& ar);
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CGyrovizDoc_4();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
|
||||
virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
|
||||
|
||||
|
||||
//unsigned char* cimg_image_multiplexer_char(const CImg <unsigned char>& image)
|
||||
//{
|
||||
// int ix,iy,i=0;
|
||||
|
||||
// unsigned char* result = new unsigned char[image.dimx()*image.dimy()*3];
|
||||
|
||||
// for(iy=image.dimy() - 1; iy >= 0; --iy)
|
||||
// {
|
||||
// for(ix=0; ix < image.dimx(); ++ix)
|
||||
// {
|
||||
// result[i++] = *(image.ptr() + image.dimx()*iy + ix);
|
||||
// result[i++] = *(image.ptr() + image.dimx()*iy + ix + image.dimx()*image.dimy());
|
||||
// result[i++] = *(image.ptr() + image.dimx()*iy + ix + image.dimx()*image.dimy()*2);
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
//}
|
||||
unsigned char* cimg_image_multiplexer_char(const CImg <unsigned char>& image)
|
||||
{
|
||||
int ix,iy,i=0;
|
||||
|
||||
unsigned char* result = new unsigned char[image.dimx()*image.dimy()*3];
|
||||
|
||||
for(iy=0; iy < image.dimy(); ++iy)
|
||||
{
|
||||
for(ix=0; ix < image.dimx(); ++ix)
|
||||
{
|
||||
result[i++] = *(image.ptr() + image.dimx()*iy + ix);
|
||||
result[i++] = *(image.ptr() + image.dimx()*iy + ix + image.dimx()*image.dimy());
|
||||
result[i++] = *(image.ptr() + image.dimx()*iy + ix + image.dimx()*image.dimy()*2);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ void CGyrovizView_2::OnPaint()
|
|||
{
|
||||
//::glColor3ub(255,0,0);
|
||||
/*pDoc->get_dt2().gl_draw_on_border_2D_vertices(255,0,0,4,pDoc->m_cimg_seg_image);*/
|
||||
pDoc->get_cdt2().gl_draw_on_border_2D_vertices(255,0,255,4,pDoc->m_cimg_seg_image);
|
||||
pDoc->get_cdt2().gl_draw_on_border_2D_vertices(255,0,255,6/*TEST,pDoc->m_cimg_seg_image*/);
|
||||
}
|
||||
|
||||
if(m_view_constraints)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
// Author : Nader Salman
|
||||
|
||||
#ifndef _Gyroviz_border_points_dt2_
|
||||
#define _Gyroviz_border_points_dt2_
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
|
||||
#include <CGAL/Delaunay_triangulation_2.h>
|
||||
|
||||
template < class Gt, class Tds >
|
||||
class Gyroviz_border_points_dt2 : public CGAL::Delaunay_triangulation_2<Gt, Tds>
|
||||
{
|
||||
// Private types
|
||||
private:
|
||||
|
||||
typedef CGAL::Delaunay_triangulation_2<Gt, Tds> Base;
|
||||
|
||||
// Public types
|
||||
public:
|
||||
|
||||
// Repeat Delaunay_triangulation_2 public types
|
||||
typedef Tds Triangulation_data_structure;
|
||||
typedef Gt Geom_traits;
|
||||
typedef typename Geom_traits::FT FT;
|
||||
typedef typename Geom_traits::Point_2 Point_2;
|
||||
typedef typename Geom_traits::Segment_2 Segment_2;
|
||||
typedef typename Base::Face_handle Face_handle;
|
||||
typedef typename Base::Vertex_handle Vertex_handle;
|
||||
typedef typename Base::Edge Edge;
|
||||
typedef typename Base::Finite_edges_iterator Finite_edges_iterator;
|
||||
typedef typename Base::Finite_faces_iterator Finite_faces_iterator;
|
||||
typedef typename Base::Finite_vertices_iterator Finite_vertices_iterator;
|
||||
|
||||
// Data members
|
||||
private:
|
||||
std::vector<Vertex_handle> input;
|
||||
|
||||
// Public methods
|
||||
public:
|
||||
|
||||
|
||||
// Constructors
|
||||
Gyroviz_border_points_dt2(){}
|
||||
Gyroviz_border_points_dt2(std::vector<Vertex_handle> in)
|
||||
{
|
||||
for(int i=0; i<in.size(); ++i)
|
||||
{
|
||||
this->insert(in[i]->point());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
// this function will store as a vector of Gyroviz_vertex_segment_2
|
||||
// the entire 2D Delaunay triangulation
|
||||
std::vector<Segment_2> segments_out_of_dt2()
|
||||
{
|
||||
std::vector<Segment_2> result;
|
||||
|
||||
Finite_edges_iterator fe = this->finite_edges_begin();
|
||||
for(; fe != this->finite_edges_end(); ++fe)
|
||||
{
|
||||
Segment_2 curr_segment(fe->first->vertex(ccw(fe->second))->point(),
|
||||
fe->first->vertex(cw(fe->second))->point());
|
||||
result.push_back(curr_segment);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // _Gyroviz_border_points_dt2_
|
||||
|
|
@ -19,6 +19,8 @@
|
|||
#include <CGAL/origin.h>
|
||||
|
||||
#include "Gyroviz_info_for_cdt2.h"
|
||||
#include "Gyroviz_vertex_segment_2.h"
|
||||
#include "Gyroviz_border_points_dt2.h"
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
|
@ -60,6 +62,7 @@ public:
|
|||
typedef typename Base::Finite_edges_iterator Finite_edges_iterator;
|
||||
typedef typename Base::Finite_faces_iterator Finite_faces_iterator;
|
||||
typedef typename Base::Finite_vertices_iterator Finite_vertices_iterator;
|
||||
typedef typename Gyroviz_vertex_segment_2<Gyroviz_cdt2> Gyroviz_vertex_segment_2;
|
||||
|
||||
// Data members
|
||||
private:
|
||||
|
|
@ -80,6 +83,11 @@ public:
|
|||
|
||||
bool read_pnt(char *pFilename)
|
||||
{
|
||||
|
||||
//DEBUG
|
||||
int number_of_vertices_pnt = 0;
|
||||
|
||||
//extract from pFilename the image number
|
||||
std::string temp ( pFilename );
|
||||
std::string filename_without_path = temp.substr(temp.size()-15);
|
||||
std::string extract_number = filename_without_path.substr(7,filename_without_path.size()-4);
|
||||
|
|
@ -113,6 +121,7 @@ public:
|
|||
|
||||
Vertex_handle vh = this->insert(point_2);
|
||||
vh->info() = Gyroviz_info_for_cdt2(point_3,image_number,false);
|
||||
number_of_vertices_pnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -122,21 +131,25 @@ public:
|
|||
}
|
||||
|
||||
|
||||
// flag the vertices positionned on the border and return a vector of these
|
||||
std::vector<Point_2> set_on_border_2D_vertices(const CImg <unsigned char> & image)
|
||||
// set flag to true for the vertices positionned on the border and return a vector of these
|
||||
std::vector<Vertex_handle> set_on_border_2D_vertices(const CImg <unsigned char> & image)
|
||||
{
|
||||
std::vector<Point_2> vector_of_border_points;
|
||||
|
||||
//DEBUG
|
||||
int number_of_border_vertices = 0;
|
||||
|
||||
std::vector<Vertex_handle> vector_of_border_points;
|
||||
|
||||
Finite_vertices_iterator fv = this->finite_vertices_begin();
|
||||
for(; fv != this->finite_vertices_end(); ++fv)
|
||||
{
|
||||
// if pixel any of 3x3 surrounding pixels is on border
|
||||
// keep vertex(white color is used in frei-chen gradient operator)
|
||||
|
||||
|
||||
if (image((unsigned int)fv->point().x(),(unsigned int)fv->point().y(),0,0)==255)
|
||||
{
|
||||
fv->info().set_flag(true);
|
||||
vector_of_border_points.push_back(fv->point());
|
||||
vector_of_border_points.push_back(fv);
|
||||
}
|
||||
|
||||
else if((unsigned int)fv->point().x() == 0 && (unsigned int)fv->point().y() == 0) //upper left pixel
|
||||
|
|
@ -146,7 +159,7 @@ public:
|
|||
image((unsigned int)fv->point().x()+1,(unsigned int)fv->point().y()+1,0,0)== 255)
|
||||
{
|
||||
fv->info().set_flag(true);
|
||||
vector_of_border_points.push_back(fv->point());
|
||||
vector_of_border_points.push_back(fv);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -157,7 +170,7 @@ public:
|
|||
image((unsigned int)fv->point().x()-1,(unsigned int)fv->point().y()+1,0,0)== 255)
|
||||
{
|
||||
fv->info().set_flag(true);
|
||||
vector_of_border_points.push_back(fv->point());
|
||||
vector_of_border_points.push_back(fv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +181,7 @@ public:
|
|||
image((unsigned int)fv->point().x()+1,(unsigned int)fv->point().y()-1,0,0)== 255)
|
||||
{
|
||||
fv->info().set_flag(true);
|
||||
vector_of_border_points.push_back(fv->point());
|
||||
vector_of_border_points.push_back(fv);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -180,7 +193,7 @@ public:
|
|||
image((unsigned int)fv->point().x()-1,(unsigned int)fv->point().y()-1,0,0)== 255)
|
||||
{
|
||||
fv->info().set_flag(true);
|
||||
vector_of_border_points.push_back(fv->point());
|
||||
vector_of_border_points.push_back(fv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +206,7 @@ public:
|
|||
image((unsigned int)fv->point().x()+1,(unsigned int)fv->point().y()+1,0,0)== 255)
|
||||
{
|
||||
fv->info().set_flag(true);
|
||||
vector_of_border_points.push_back(fv->point());
|
||||
vector_of_border_points.push_back(fv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +219,7 @@ public:
|
|||
image((unsigned int)fv->point().x()+1,(unsigned int)fv->point().y(),0,0) == 255)
|
||||
{
|
||||
fv->info().set_flag(true);
|
||||
vector_of_border_points.push_back(fv->point());
|
||||
vector_of_border_points.push_back(fv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +232,7 @@ public:
|
|||
image((unsigned int)fv->point().x(), (unsigned int)fv->point().y()+1,0,0)== 255)
|
||||
{
|
||||
fv->info().set_flag(true);
|
||||
vector_of_border_points.push_back(fv->point());
|
||||
vector_of_border_points.push_back(fv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +245,7 @@ public:
|
|||
image((unsigned int)fv->point().x(), (unsigned int)fv->point().y()+1,0,0)== 255)
|
||||
{
|
||||
fv->info().set_flag(true);
|
||||
vector_of_border_points.push_back(fv->point());
|
||||
vector_of_border_points.push_back(fv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -248,10 +261,13 @@ public:
|
|||
image((unsigned int)fv->point().x()+1,(unsigned int)fv->point().y()+1,0,0)== 255)
|
||||
{
|
||||
fv->info().set_flag(true);
|
||||
vector_of_border_points.push_back(fv->point());
|
||||
vector_of_border_points.push_back(fv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
number_of_border_vertices = vector_of_border_points.size();
|
||||
|
||||
return vector_of_border_points;
|
||||
}
|
||||
|
||||
|
|
@ -273,21 +289,26 @@ public:
|
|||
}
|
||||
|
||||
|
||||
// this function will draw segments between all border points
|
||||
std::vector<Segment_2> link_points_on_border(std::vector<Point_2> vector_of_border_points)
|
||||
// (DEPRECATED)this function will draw segments between all border points
|
||||
std::vector<Gyroviz_vertex_segment_2> link_points_on_border(const std::vector<Vertex_handle>& vector_of_border_points)
|
||||
{
|
||||
std::vector<Segment_2> vector_of_segments;
|
||||
//DEBUG
|
||||
int number_of_segments = 0;
|
||||
|
||||
std::vector<Gyroviz_vertex_segment_2> vector_of_vertex_segments;
|
||||
|
||||
for(int i = 0; i<vector_of_border_points.size()-1; ++i)
|
||||
for(int i=0; i<vector_of_border_points.size()-1; ++i)
|
||||
{
|
||||
for(int j =i+1; j<vector_of_border_points.size(); ++j)
|
||||
for(int j=i+1; j<vector_of_border_points.size(); ++j)
|
||||
{
|
||||
Segment_2 s(vector_of_border_points[i],vector_of_border_points[j]);
|
||||
vector_of_segments.push_back(s);
|
||||
Gyroviz_vertex_segment_2 vertex_segment(vector_of_border_points[i],vector_of_border_points[j]);
|
||||
vector_of_vertex_segments.push_back(vertex_segment);
|
||||
}
|
||||
}
|
||||
|
||||
return vector_of_segments;
|
||||
number_of_segments = vector_of_vertex_segments.size();
|
||||
|
||||
return vector_of_vertex_segments;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -305,8 +326,26 @@ public:
|
|||
std::vector<Segment_2> nw_add_constraints(const CImg <unsigned char>& image, int gap_score)
|
||||
{
|
||||
|
||||
std::vector<Point_2> vector_of_border_points = set_on_border_2D_vertices(image);
|
||||
std::vector<Segment_2> vector_of_segments = link_points_on_border(vector_of_border_points);
|
||||
std::vector<Vertex_handle> vector_of_border_points = set_on_border_2D_vertices(image);
|
||||
|
||||
Gyroviz_border_points_dt2<Gt, Tds> border_dt2(vector_of_border_points);
|
||||
|
||||
std::vector<Segment_2> vector_of_segments = border_dt2.segments_out_of_dt2();
|
||||
|
||||
//std::vector<Gyroviz_vertex_segment_2> vector_of_vertex_segments = link_points_on_border(vector_of_border_points);
|
||||
|
||||
//DEBUG
|
||||
int vector_of_border_points_size = vector_of_border_points.size();
|
||||
int vector_of_segments_size = vector_of_segments.size();
|
||||
|
||||
int BEFORE_constraints_number_of_vertices=0;
|
||||
|
||||
|
||||
for(Finite_vertices_iterator fv = this->finite_vertices_begin(); fv != this->finite_vertices_end(); ++fv)
|
||||
{
|
||||
BEFORE_constraints_number_of_vertices++;
|
||||
}
|
||||
|
||||
|
||||
Point_2 source_vertex;
|
||||
Point_2 end_vertex;
|
||||
|
|
@ -314,44 +353,67 @@ public:
|
|||
std::vector<Segment_2> vector_of_constraints;
|
||||
|
||||
double length_curr_segment = 0;
|
||||
int global_score = 0;// no constraint
|
||||
int global_score = -1;// no constraint
|
||||
|
||||
// the similarity matrix i will use is
|
||||
// S(Border/Segment) = +1
|
||||
// S(Gap/Segment) = gap_score (default : -2)
|
||||
|
||||
for(int i = 0; i<vector_of_segments.size(); ++i)
|
||||
for(int i = 0; i</*vector_of_vertex_segments*/vector_of_segments.size(); ++i)
|
||||
{
|
||||
//source_vertex = vector_of_vertex_segments[i].get_source()->point();
|
||||
//end_vertex = vector_of_vertex_segments[i].get_target()->point();
|
||||
//Segment_2 s (source_vertex, end_vertex);
|
||||
|
||||
source_vertex = vector_of_segments[i].source();
|
||||
end_vertex = vector_of_segments[i].target();
|
||||
Segment_2 s = vector_of_segments[i];
|
||||
source_vertex = s.source();
|
||||
end_vertex = s.target();
|
||||
v = end_vertex - source_vertex;
|
||||
|
||||
length_curr_segment = (int)ceil(sqrt(s.squared_length()));
|
||||
int current_gap_score = gap_score;
|
||||
|
||||
for(int j = 0; j<length_curr_segment; ++j)
|
||||
{
|
||||
{ //TO OPTIMIZE
|
||||
if(image((unsigned int)point_on_segment(v, source_vertex, j/length_curr_segment).x(),
|
||||
(unsigned int)point_on_segment(v, source_vertex, j/length_curr_segment).y(), 0, 0) == 255)
|
||||
(unsigned int)point_on_segment(v, source_vertex, j/length_curr_segment).y(), 0, 0) == 255 &&
|
||||
image((unsigned int)point_on_segment(v, source_vertex, j/length_curr_segment).x(),
|
||||
(unsigned int)point_on_segment(v, source_vertex, j/length_curr_segment).y(), 0, 1) == 255 &&
|
||||
image((unsigned int)point_on_segment(v, source_vertex, j/length_curr_segment).x(),
|
||||
(unsigned int)point_on_segment(v, source_vertex, j/length_curr_segment).y(), 0, 2) == 255)
|
||||
{
|
||||
global_score = global_score + 3;
|
||||
global_score = global_score + current_gap_score;
|
||||
current_gap_score = gap_score;
|
||||
}
|
||||
else
|
||||
{
|
||||
global_score = global_score - current_gap_score;
|
||||
current_gap_score++;
|
||||
global_score = global_score - current_gap_score/*/gap_score*/; //TEST
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(global_score >= 0)
|
||||
{
|
||||
this->insert_constraint(source_vertex,end_vertex);
|
||||
|
||||
this->insert_constraint(source_vertex,end_vertex/*vector_of_vertex_segments[i].get_source(),vector_of_vertex_segments[i].get_target()*/);
|
||||
vector_of_constraints.push_back(s);
|
||||
global_score = 0;
|
||||
}
|
||||
else
|
||||
global_score = 0;
|
||||
}
|
||||
|
||||
|
||||
// DEBUG
|
||||
int AFTER_constraints_number_of_vertices=0;
|
||||
|
||||
|
||||
for(Finite_vertices_iterator fv = this->finite_vertices_begin(); fv != this->finite_vertices_end(); ++fv)
|
||||
{
|
||||
AFTER_constraints_number_of_vertices++;
|
||||
}
|
||||
|
||||
return vector_of_constraints;
|
||||
}
|
||||
|
||||
|
|
@ -432,6 +494,9 @@ public:
|
|||
void gl_draw_2D_vertices(const unsigned char r, const unsigned char g,
|
||||
const unsigned char b, float size)
|
||||
{
|
||||
//DEBUG
|
||||
int number_of_vertices_2v = 0;
|
||||
|
||||
::glPointSize(size);
|
||||
::glColor3ub(r,g,b);
|
||||
::glBegin(GL_POINTS);
|
||||
|
|
@ -440,15 +505,22 @@ public:
|
|||
for(; fv != this->finite_vertices_end(); ++fv)
|
||||
{
|
||||
::glVertex2d(fv->point().x(),fv->point().y());
|
||||
|
||||
|
||||
number_of_vertices_2v++;
|
||||
}
|
||||
|
||||
::glEnd();
|
||||
}
|
||||
|
||||
|
||||
// draw 2D only points near detected borders
|
||||
void gl_draw_on_border_2D_vertices(const unsigned char r, const unsigned char g,
|
||||
const unsigned char b, float size, const CImg <unsigned char>& image)
|
||||
const unsigned char b, float size/* TEST, const CImg <unsigned char>& image*/)
|
||||
{
|
||||
/*
|
||||
TEST
|
||||
|
||||
::glPointSize(size);
|
||||
::glColor3ub(r,g,b);
|
||||
::glBegin(GL_POINTS);
|
||||
|
|
@ -456,9 +528,30 @@ public:
|
|||
std::vector<Point_2> vector_of_border_points = set_on_border_2D_vertices(image);
|
||||
for(int i=0; i<vector_of_border_points.size(); ++i)
|
||||
{
|
||||
::glVertex2d(vector_of_border_points[i].x(),vector_of_border_points[i].y());
|
||||
::glVertex2d(vector_of_border_points[i].x(),vector_of_border_points[i].y());
|
||||
}
|
||||
::glEnd();*/
|
||||
|
||||
//DEBUG
|
||||
int number_of_vertices_b = 0;
|
||||
|
||||
::glPointSize(size);
|
||||
::glColor3ub(r,g,b);
|
||||
::glBegin(GL_POINTS);
|
||||
|
||||
Finite_vertices_iterator fv = this->finite_vertices_begin();
|
||||
for(; fv != this->finite_vertices_end(); ++fv)
|
||||
{
|
||||
if(fv->info().get_flag()){
|
||||
::glVertex2d(fv->point().x(),fv->point().y());
|
||||
|
||||
number_of_vertices_b++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
::glEnd();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -513,6 +606,7 @@ public:
|
|||
|
||||
::glLineWidth(line_width);
|
||||
::glBegin(GL_LINES);
|
||||
|
||||
Finite_edges_iterator fe = this->finite_edges_begin();
|
||||
for(; fe != this->finite_edges_end(); ++fe)
|
||||
{
|
||||
|
|
@ -534,6 +628,9 @@ public:
|
|||
void gl_draw_soup_vertices(const unsigned char r, const unsigned char g,
|
||||
const unsigned char b, float size)
|
||||
{
|
||||
//DEBUG
|
||||
int number_of_vertices_sv = 0;
|
||||
|
||||
::glPointSize(size);
|
||||
::glColor3ub(r,g,b);
|
||||
::glBegin(GL_POINTS);
|
||||
|
|
@ -543,34 +640,67 @@ public:
|
|||
{
|
||||
const Point_3& p = fv->info().get_point3();
|
||||
::glVertex3d(p.x(),p.y(),p.z());
|
||||
}
|
||||
|
||||
number_of_vertices_sv++;
|
||||
|
||||
}
|
||||
::glEnd();
|
||||
}
|
||||
|
||||
|
||||
// draw 2D only points near detected borders
|
||||
void gl_draw_on_border_3D_vertices(const unsigned char r, const unsigned char g,
|
||||
const unsigned char b, float size)
|
||||
{
|
||||
//DEBUG
|
||||
int number_of_vertices_bv = 0;
|
||||
|
||||
::glPointSize(size);
|
||||
::glColor3ub(r,g,b);
|
||||
::glBegin(GL_POINTS);
|
||||
|
||||
Finite_vertices_iterator fv = this->finite_vertices_begin();
|
||||
for(; fv != this->finite_vertices_end(); ++fv)
|
||||
{
|
||||
if(fv->info().get_flag())
|
||||
{
|
||||
::glVertex3d(fv->info().get_point3().x(),fv->info().get_point3().y(),fv->info().get_point3().z());
|
||||
|
||||
number_of_vertices_bv++;
|
||||
|
||||
}
|
||||
}
|
||||
::glEnd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 3D projection of the tracked 2D constrained edges
|
||||
void gl_draw_soup_constrained_edges(const unsigned char r, const unsigned char g,
|
||||
const unsigned char b, const float width, const CImg <unsigned char>& image)
|
||||
const unsigned char b, const float width/*, const CImg <unsigned char>& image*/)
|
||||
{
|
||||
::glLineWidth(width);
|
||||
::glColor3ub(r,g,b);
|
||||
::glBegin(GL_LINES);
|
||||
|
||||
std::vector<Segment_2> vector_of_constraints = nw_add_constraints(image);
|
||||
for(int i=0; i<vector_of_constraints.size(), ++i)
|
||||
/*std::vector<Segment_2> vector_of_constraints = nw_add_constraints(image);*/
|
||||
Finite_edges_iterator fe = this->finite_edges_begin();
|
||||
for(; fe != this->finite_edges_end(); ++fe)
|
||||
{
|
||||
::glVertex3d(vector_of_constraints[i].source()->info().get_point3().x(),
|
||||
vector_of_constraints[i].source()->info().get_point3().y(),
|
||||
vector_of_constraints[i].source()->info().get_point3().z());
|
||||
::glVertex3d(vector_of_constraints[i].target()->info().get_point3().x(),
|
||||
vector_of_constraints[i].target()->info().get_point3().y(),
|
||||
vector_of_constraints[i].target()->info().get_point3().z());
|
||||
}
|
||||
::glEnd();
|
||||
if(fe->first->is_constrained(fe->second))
|
||||
{
|
||||
Point_3 p1 = fe->first->vertex(ccw(fe->second))->info().get_point3();
|
||||
Point_3 p2 = fe->first->vertex(cw(fe->second))->info().get_point3();
|
||||
::glVertex3d(p1.x(), p1.y(), p1.z());
|
||||
::glVertex3d(p2.x(), p2.y(), p2.z());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
::glEnd();
|
||||
}
|
||||
|
||||
|
||||
// 3D projection of the tracked 2D constrained triangulation
|
||||
void gl_draw_soup_constrained_triangles(const unsigned char r, const unsigned char g,
|
||||
const unsigned char b){
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ protected:
|
|||
|
||||
// 3D Point
|
||||
Point_3 point;
|
||||
|
||||
|
||||
// Camera number
|
||||
int camera_number;
|
||||
|
||||
// Flag := on border or not
|
||||
bool flag;
|
||||
|
||||
// Flag := on border or not
|
||||
bool flag;
|
||||
|
||||
public:
|
||||
Gyroviz_info_for_cdt2(){}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
#include <stdio.h>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
//#define cimg_convert_path "C:\Users\nsalman\Documents\ImageMagick\ImageMagick-6.4.0\VisualMagick\bin\convert"
|
||||
#include <CImg.h>
|
||||
using namespace cimg_library;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/Zm900"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="include;..\..\..\include;..\..\..\..\..\trunk\Principal_component_analysis\include;..\..\..\..\..\trunk\Jet_fitting_3\include;"$(CGALROOT)\include\CGAL\config\msvc";"$(CGALROOT)\include";"$(CGALROOT)\auxiliary\gmp\include";"$(CGALROOT)\auxiliary\taucs\include";"$(BOOSTROOT)";"$(CIMGROOT)""
|
||||
AdditionalIncludeDirectories="include;..\..\..\include;..\..\..\..\..\trunk\Principal_component_analysis\include;..\..\..\..\..\trunk\Jet_fitting_3\include;"$(CGALROOT)\include\CGAL\config\msvc";"$(CGALROOT)\include";"$(CGALROOT)\auxiliary\gmp\include";"$(CGALROOT)\auxiliary\taucs\include";"$(BOOSTROOT)";"$(CIMGROOT)";"$(convert)""
|
||||
PreprocessorDefinitions="WIN32;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;CGAL_USE_GMP;CGAL_USE_TAUCS;_WIN32_WINNT= 0x0500;CGAL_PROFILE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="0"
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
AdditionalOptions="/Zm900"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="include;..\..\..\include;..\..\..\..\..\trunk\Principal_component_analysis\include;..\..\..\..\..\trunk\Jet_fitting_3\include;"$(CGALROOT)\include\CGAL\config\msvc";"$(CGALROOT)\include";"$(CGALROOT)\auxiliary\gmp\include";"$(CGALROOT)\auxiliary\taucs\include";"$(BOOSTROOT)";"$(CIMGROOT)""
|
||||
AdditionalIncludeDirectories="include;..\..\..\include;..\..\..\..\..\trunk\Principal_component_analysis\include;..\..\..\..\..\trunk\Jet_fitting_3\include;"$(CGALROOT)\include\CGAL\config\msvc";"$(CGALROOT)\include";"$(CGALROOT)\auxiliary\gmp\include";"$(CGALROOT)\auxiliary\taucs\include";"$(BOOSTROOT)";"$(CIMGROOT)";"$(convert)""
|
||||
PreprocessorDefinitions="WIN32;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;CGAL_USE_GMP;CGAL_USE_TAUCS;_WIN32_WINNT= 0x0500;CGAL_PROFILE"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="0"
|
||||
|
|
@ -223,6 +223,10 @@
|
|||
RelativePath=".\DialogOptions_3.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DialogOptions_4.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Director.cpp"
|
||||
>
|
||||
|
|
@ -239,6 +243,10 @@
|
|||
RelativePath=".\GyrovizDoc_3.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GyrovizDoc_4.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GyrovizView_2.cpp"
|
||||
>
|
||||
|
|
@ -247,6 +255,10 @@
|
|||
RelativePath=".\GyrovizView_3.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GyrovizView_4.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\MainFrm.cpp"
|
||||
>
|
||||
|
|
@ -297,6 +309,10 @@
|
|||
RelativePath=".\DialogOptions_3.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DialogOptions_4.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Director.h"
|
||||
>
|
||||
|
|
@ -309,6 +325,10 @@
|
|||
RelativePath=".\Gyroviz.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Gyroviz_border_points_dt2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Gyroviz_cdt2.h"
|
||||
>
|
||||
|
|
@ -345,6 +365,10 @@
|
|||
RelativePath=".\Gyroviz_segmented_dt3.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Gyroviz_vertex_segment_2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GyrovizDoc_2.h"
|
||||
>
|
||||
|
|
@ -353,6 +377,10 @@
|
|||
RelativePath=".\GyrovizDoc_3.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GyrovizDoc_4.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GyrovizKernel.h"
|
||||
>
|
||||
|
|
@ -365,6 +393,10 @@
|
|||
RelativePath=".\GyrovizView_3.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GyrovizView_4.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\MainFrm.h"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
// Author : Nader Salman
|
||||
|
||||
|
||||
// an object used to store a segment_2 as a couple of vertices Source & Target
|
||||
// will be used to insert constraints in the 2D Delaunay triangulation
|
||||
// function: ct.insert_constraint ( Vertex_handle va, Vertex_handle vb)
|
||||
// Inserts the line segment s whose endpoints are the vertices
|
||||
// va and vb as a constrained edge e. The triangles intersected
|
||||
// by s are removed and new ones are created.
|
||||
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||
|
||||
template < class Triangulation >
|
||||
class Gyroviz_vertex_segment_2
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
typedef typename Triangulation::Vertex_handle Vertex_handle;
|
||||
|
||||
// Vertex_handles
|
||||
Vertex_handle source;
|
||||
Vertex_handle target;
|
||||
|
||||
|
||||
public:
|
||||
Gyroviz_vertex_segment_2(){}
|
||||
Gyroviz_vertex_segment_2(Vertex_handle va, Vertex_handle vb):source(va),target(vb){}
|
||||
|
||||
// accessors
|
||||
const Vertex_handle get_source() const { return source; }
|
||||
const Vertex_handle get_target() const { return target; }
|
||||
|
||||
// modificators
|
||||
void set_source(Vertex_handle va) { source=va; }
|
||||
void set_target(Vertex_handle vb) { target=vb; }
|
||||
};
|
||||
|
|
@ -119,8 +119,7 @@ public:
|
|||
Point_3 point_3(x,y,z);
|
||||
|
||||
Vertex_handle vh = this->insert(point_2);
|
||||
|
||||
vh->info() = Gyroviz_info_for_dt2(point_3,image_number);
|
||||
vh->info() = Gyroviz_info_for_dt2(point_3,image_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#pragma once
|
||||
#include "Director.h"
|
||||
|
||||
class Arcball
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
#define IDD_DIALOG_OPTIONS_3 134
|
||||
#define IDR_GyrovizTYPE_2 135
|
||||
#define IDD_DIALOG_OPTIONS2 136
|
||||
#define IDR_GyrovizTYPE_4 137
|
||||
#define IDD_DIALOG_OPTIONS_4 138
|
||||
#define IDC_EDIT_SM_ANGLE 1000
|
||||
#define IDC_EDIT_SM_RADIUS 1001
|
||||
#define IDC_EDIT_SM_DISTANCE 1002
|
||||
|
|
@ -60,13 +62,14 @@
|
|||
#define ID_RENDERCOFF_INSIDE 32840
|
||||
#define ID_RENDERCOFF_CAMERAS 32841
|
||||
#define ID_RENDER_CONSTRAINTS 32842
|
||||
#define ID_RENDER_BORDERVERTICES32845 32845
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 137
|
||||
#define _APS_NEXT_COMMAND_VALUE 32843
|
||||
#define _APS_NEXT_RESOURCE_VALUE 139
|
||||
#define _APS_NEXT_COMMAND_VALUE 32847
|
||||
#define _APS_NEXT_CONTROL_VALUE 1007
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue