本文整理汇总了C++中DImage::imwrite方法的典型用法代码示例。如果您正苦于以下问题:C++ DImage::imwrite方法的具体用法?C++ DImage::imwrite怎么用?C++ DImage::imwrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DImage
的用法示例。
在下文中一共展示了DImage::imwrite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnOpenDocument
BOOL CsMIShopDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// open CVoxel object
m_pVoxel = new CVoxel<short>(lpszPathName);
m_pDrawLayerZ = new cv::Mat[m_pVoxel->m_nZ];
m_pDrawLayerY = new cv::Mat[m_pVoxel->m_nY];
m_pDrawLayerX = new cv::Mat[m_pVoxel->m_nX];
for (int i = 0; i < m_pVoxel->m_nZ; i++)
m_pDrawLayerZ[i].create(m_pVoxel->m_nY,m_pVoxel->m_nX,CV_8UC1);
for (int i = 0; i < m_pVoxel->m_nY; i++)
m_pDrawLayerY[i].create(m_pVoxel->m_nX, m_pVoxel->m_nZ, CV_8UC1);
for (int i = 0; i < m_pVoxel->m_nX; i++)
m_pDrawLayerX[i].create(m_pVoxel->m_nZ,m_pVoxel->m_nY,CV_8UC1);
m_iMaxValue = m_pVoxel->m_nMaxI;
m_iMinValue = m_pVoxel->m_nMinI;
//for(int z = 0; z < m_pVoxel->m_nZ; z++)
//for(int y = 0; y < m_pVoxel->m_nY; y++)
//for(int x = 0; x < m_pVoxel->m_nX; x++)
//{
// if(m_pVoxel->m_pData[z*m_pVoxel->m_nY*m_pVoxel->m_nX + y*m_pVoxel->m_nX + x] > m_iMaxValue)
// m_iMaxValue = m_pVoxel->m_pData[z*m_pVoxel->m_nY*m_pVoxel->m_nX + y*m_pVoxel->m_nX + x];
// if (m_pVoxel->m_pData[z*m_pVoxel->m_nY*m_pVoxel->m_nX + y*m_pVoxel->m_nX + x] < m_iMinValue)
// m_iMinValue = m_pVoxel->m_pData[z*m_pVoxel->m_nY*m_pVoxel->m_nX + y*m_pVoxel->m_nX + x];
//
//}
#if 0
// TEST 3: to warp with thin-plate spline - layer separation
#endif
#if 0
// TEST 2: try to extract bone (which has no motion)
int imgw = m_pVoxel->m_nX;
int imgh = m_pVoxel->m_nY;
int nfrm = m_pVoxel->m_nZ;
// construct average image
cv::Mat avg = cv::Mat::zeros(imgh, imgw, CV_32F);
for ( int y = 0; y < m_pVoxel->m_nY; y++ ) {
float *avgp = avg.ptr<float>(y);
for ( int x = 0; x < m_pVoxel->m_nX; x++ ) {
for ( int i = 0; i < m_pVoxel->m_nZ; i++ ) {
avgp[x] += m_pVoxel->GetAt(x,y,i);
}
}
}
avg = avg/(float)nfrm;
// save average image
cv::Mat avg_8u;
avg.convertTo(avg_8u, CV_8U);
cv::imwrite("avg_img.png", avg_8u);
// compute subtraction image for all frames
for ( int i = 0; i < nfrm; i++ ) {
cv::Mat frm_idx = m_pVoxel->VoxelZSlice2cvMat<short>(i);
cv::Mat frm_idx_f;
frm_idx.convertTo(frm_idx_f, CV_32F);
cv::Mat frm_sub = cv::abs(frm_idx_f - avg);
double minf, maxf;
cv::minMaxIdx(frm_sub, &minf, &maxf);
cv::Mat frm_sub_8u;
frm_sub.convertTo(frm_sub_8u, CV_8U, 255.0/(maxf-minf), -minf);
char path[MAX_PATH];
sprintf(path, "frm_sub_%04d.png", i);
cv::imwrite(path, frm_sub_8u);
}
#endif
// TEST 1: compare optical flow between consecutive and synchronized frames
// 20140825 ****** OPTICAL FLOW FAILS TOTALLY FOR 2D+t CARDIAC X-RAY IMAGES ****** //
#if 0
//////////////////////////////////////////////////////////
// 20140820 *** ASSUME VESSEL IMAGE HAS BEEN LOADED *** //
// set the parameters
// para(1)--alpha (1), the regularization weight
// para(2)--ratio (0.5), the downsample ratio
// para(3)--minWidth (40), the width of the coarsest level
// para(4)--nOuterFPIterations (3), the number of outer fixed point iterations
// para(5)--nInnerFPIterations (1), the number of inner fixed point iterations
// para(6)--nSORIterations (20), the number of SOR iterations
double alpha= 0.012;
double ratio=0.75;
int minWidth= 32;
int nOuterFPIterations = 5;//5;
int nInnerFPIterations = 1;//3;
int nSORIterations= 20;//40;
// compute optical flow between consecutive frames
int n_src = 24;
int n_dst = 36;
DImage frm_src = m_pVoxel->VoxelZSlice2DImage(n_src);
//.........这里部分代码省略.........