📄 imagefeaturesdoc.cpp
字号:
pCmdUI->SetCheck(m_process.m_viewEdgesOnly);
}
/*------------------------------------------------------------------------*/
bool CImageFeaturesDoc::DisplayText()
{
WindowNew();
// To do: display the test
return true;
}
/*------------------------------------------------------------------------*/
// Not yet used. Sample code for opening a window for text or graphics.
void CImageFeaturesDoc::WindowNew()
// void CMDIFrameWnd::OnWindowNew()
{
// Get a pointer to the active MDI child window.
/* CMDIChildWnd* pActiveChild = MDIGetActive();
// CFrameWnd* pFrame = pView->GetParentFrame();
CDocument* pDocument;
if (pActiveChild == NULL ||
(pDocument = pActiveChild->GetActiveDocument()) == NULL)
{
TRACE0("Warning: No active document for WindowNew command.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
return; // command failed
}
// otherwise we have a new frame !
CDocTemplate* pTemplate = pDocument->GetDocTemplate();
ASSERT_VALID(pTemplate);
CFrameWnd* pFrame = pTemplate->CreateNewFrame(pDocument, pActiveChild);
if (pFrame == NULL)
{
TRACE0("Warning: failed to create new frame.\n");
return; // command failed
}
pTemplate->InitialUpdateFrame(pFrame, pDocument);
*/
}
/*------------------------------------------------------------------------*/
// Graphical version of features overlaid on the image.
void CImageFeaturesDoc::DisplayFeatureImage()
{
PROFILE("DisplayFeatureImage");
// Create an RGBA version of the image compatible with
// Windows drawing.
CVisRGBAByteImage featureImage( m_image.Rect() );
m_image.CopyPixelsTo( featureImage );
// draw graphics on the image.
m_process.MakeFeatureImage( featureImage );
CVisPane featureImagePane = VisDisplayImage( /* m_image.Rect(), */
featureImage, evispanedispDefault, "Features found" );
// For some reason, the lines drawn in featureImage show up in m_image
}
/*------------------------------------------------------------------------*/
void CImageFeaturesDoc::OnProcessOptions()
{
COptions optionsDialog;
optionsDialog.TransferData( &m_process, true);
optionsDialog.DoModal();
optionsDialog.TransferData( &m_process, false);
}
/*------------------------------------------------------------------------*/
void CImageFeaturesDoc::OnProcessTestEdges()
{
int width = 4 * m_process.m_filterDiam;
int height = 4 * m_process.m_filterDiam;
CTestImage base( width, height );
int mode = ios::out;
char title[80];
CTime theTime = CTime::GetCurrentTime();
CString date = theTime.Format( "%B %d, %Y" ); // date == "March 19, 1991"
sprintf(title, "Edges of contrast %d on %s.",
m_process.m_testImageContrast, LPCTSTR(date));
for (int angle = 90; angle >= 40; angle -= 10)
{
base.MakeEdge( m_process.m_testImageContrast );
base.Rotate(angle);
m_image.Allocate(base.Rect());
m_process.SetBounds(base.Rect());
base.CopyPixelsTo(m_image);
float x = ((float) width - 3) / 2;
float y = ((float) height - 3) / 2;
m_process.Process( eTest1D );
m_process.SetAnswer( eEDGE, x, y, (float) angle,
(float) m_process.m_testImageContrast / MEDIUM_GRAY );
m_process.WriteFeatureList(2, mode, title);
if (m_process.m_displayTestImages)
{
DisplayFeatureImage();
}
base.AddNoise( m_process.m_testImageNoise);
m_image.Allocate(base.Rect());
base.CopyPixelsTo(m_image);
m_process.Process( eTest1D );
mode = ios::app;
m_process.WriteFeatureList(2, mode, title, m_process.m_testImageNoise);
if (m_process.m_displayTestImages)
{
DisplayFeatureImage();
}
}
}
/*------------------------------------------------------------------------*/
void CImageFeaturesDoc::OnProcessTestEdgeResolution()
{
int oldDiam = m_process.m_filterDiam;
bool oldDisplay = m_process.m_displayTestImages;
m_process.m_displayTestImages = false;
for (int diam = 21; diam > 3; diam--)
{
m_process.m_filterDiam = diam;
OnProcessTestEdges();
}
m_process.m_filterDiam = oldDiam;
m_process.m_displayTestImages = oldDisplay;
}
/*------------------------------------------------------------------------*/
void CImageFeaturesDoc::OnProcessTestBars()
{
int width = 4 * m_process.m_filterDiam;
int height = 4 * m_process.m_filterDiam;
CTestImage base( width, height );
int mode = ios::out;
char title[80];
CTime theTime = CTime::GetCurrentTime();
CString date = theTime.Format( "%B %d, %Y" ); // date == "March 19, 1991"
sprintf(title, "Bars of contrast %d on %s.",
m_process.m_testImageContrast, LPCTSTR(date));
for (int angle = 90; angle >= 85; angle -= 10)
{
for (int barWidth = m_process.m_filterDiam/2; barWidth > 1; barWidth /= 2)
{
base.MakeBar( m_process.m_testImageContrast, barWidth );
base.Rotate(angle);
m_image.Allocate(base.Rect());
m_process.SetBounds(base.Rect());
base.CopyPixelsTo(m_image);
float x = (float) width / 2;
if ((barWidth & 1) == 0)
x -= 0.5; // even bar width
float y = ((float) height - 3) / 2;
m_process.Process( eTest1D );
m_process.SetAnswer( eWHITE_LINE, x, y, (float) angle,
(float) m_process.m_testImageContrast / MEDIUM_GRAY,
(float) barWidth );
m_process.WriteFeatureList(2, mode, title);
if (m_process.m_displayTestImages)
{
DisplayFeatureImage();
}
base.AddNoise( m_process.m_testImageNoise);
m_image.Allocate(base.Rect());
base.CopyPixelsTo(m_image);
m_process.Process( eTest1D );
mode = ios::app;
m_process.WriteFeatureList(2, mode, title, m_process.m_testImageNoise);
if (m_process.m_displayTestImages)
{
DisplayFeatureImage();
}
} // loop on barWidth
}
}
/*------------------------------------------------------------------------*/
void CImageFeaturesDoc::OnProcessTestBarResolurion()
{
int oldDiam = m_process.m_filterDiam;
bool oldDisplay = m_process.m_displayTestImages;
m_process.m_displayTestImages = false;
for (int diam = 21; diam > 3; diam--)
{
m_process.m_filterDiam = diam;
OnProcessTestEdges();
}
m_process.m_filterDiam = oldDiam;
m_process.m_displayTestImages = oldDisplay;
}
/*------------------------------------------------------------------------*/
void CImageFeaturesDoc::OnProcessTestCorners()
{
int width = 4 * m_process.m_filterDiam;
int height = 4 * m_process.m_filterDiam;
CTestImage base( width, height );
int mode = ios::out;
char title[80];
CTime theTime = CTime::GetCurrentTime();
CString date = theTime.Format( "%B %d, %Y" ); // date == "March 19, 1991"
sprintf(title, "Corners of contrast %d on %s.",
m_process.m_testImageContrast, LPCTSTR(date));
for (int angle = 180; angle >= 0; angle -= 20)
{
base.MakeCorner( m_process.m_testImageContrast );
base.Rotate(angle);
m_image.Allocate(base.Rect());
m_process.SetBounds(base.Rect());
base.CopyPixelsTo(m_image);
float x = (float) (width - 1) / 2;
float y = (float) (height - 1) / 2;
m_process.Process( eTest2D );
m_process.SetAnswer( eDARK_CORNER, x, y, (float) angle,
(float) m_process.m_testImageContrast / MEDIUM_GRAY );
m_process.WriteFeatureList(2, mode, title);
if (m_process.m_displayTestImages)
{
DisplayFeatureImage();
}
/*
base.AddNoise( m_process.m_testImageNoise);
m_image.Allocate(base.Rect());
base.CopyPixelsTo(m_image);
m_process.Process( eTest1D );
mode = ios::app;
m_process.WriteFeatureList(2, mode, title, m_process.m_testImageNoise);
if (m_process.m_displayTestImages)
{
DisplayFeatureImage();
} */
}
}
/*------------------------------------------------------------------------*/
void CImageFeaturesDoc::OnProcessTestTaperedBars()
{
// TODO: Add your command handler code here
}
void CImageFeaturesDoc::OnProcessTestStoppedBars()
{
// TODO: Add your command handler code here
}
void CImageFeaturesDoc::OnProcessTestSolid3way()
{
// TODO: Add your command handler code here
}
void CImageFeaturesDoc::OnProcessTestSeparatedCorners()
{
// TODO: Add your command handler code here
}
void CImageFeaturesDoc::OnProcessTestForks()
{
// TODO: Add your command handler code here
}
void CImageFeaturesDoc::OnProcessTest2Corners()
{
// TODO: Add your command handler code here
}
void CImageFeaturesDoc::OnProcessTestDisks()
{
// TODO: Add your command handler code here
}
void CImageFeaturesDoc::OnProcessTestCurves()
{
// TODO: Add your command handler code here
}
void CImageFeaturesDoc::OnProcessTestCross()
{
// TODO: Add your command handler code here
}
void CImageFeaturesDoc::OnProcessTestBlobs()
{
// TODO: Add your command handler code here
}
void CImageFeaturesDoc::OnProcessTestAngleBars()
{
// TODO: Add your command handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -