分类: C/C++
2008-08-04 09:37:12
void CFigureView::OnPsCanny() { // TODO: 在此添加命令处理程序代码 CWaitCursor WaitCursor; int nWidth = m_imageFile.GetWidth(); int nHeight= m_imageFile.GetHeight(); // 开辟内存,存储图象数据 unsigned char * pUnchImage = new unsigned char[nWidth*nHeight]; // 将图像数据保存在矩阵当中 for(int y = 0;yCanny算子效果:>16)?0:255; g = (0x000000ff&pUnchEdge[y*nWidth x]>>8)?0:255; b = (0x000000ff&pUnchEdge[y*nWidth x])?0:255; Result = ((r g b)/3); m_imageFile.SetPixelRGB(x,y,Result,Result,Result); } } MakeBlackWhiteImage(m_imageFile,0); delete []pUnchImage; pUnchImage = NULL ; delete []pUnchEdge ; pUnchEdge = NULL ; CFigureDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; pDoc->SetModifiedFlag(TRUE); Invalidate(); }
黑白处理的 | canny算子的效果 |