本文整理汇总了C++中Image::Access方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::Access方法的具体用法?C++ Image::Access怎么用?C++ Image::Access使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::Access方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fdcm2cv
void fdcm2cv(Image<float> &fdcmImage, Mat &cvImage)
{
cvImage.create(fdcmImage.height(), fdcmImage.width(), CV_32FC1);
memcpy(cvImage.data, fdcmImage.data, cvImage.total() * sizeof(float));
//TODO: remove
for (int i = 0; i < cvImage.rows; ++i)
{
for (int j = 0; j < cvImage.cols; ++j)
{
CV_Assert(cvImage.at<float>(i, j) == fdcmImage.Access(j, i));
}
}
}
示例2: main
//.........这里部分代码省略.........
++count;
}
}
}
std::cout << count << " images total ..." << std::endl;
boost::timer timer;
double totalTime = 0;
int eightConnected = 1;
if (parameters.find("four-connected") != parameters.end()) {
eightConnected = 0;
}
int superpixels = parameters["superpixels"].as<int>();
int kernel = 0;
double lambda = parameters["lambda"].as<double>();
double sigma = parameters["sigma"].as<double>();
MERCLazyGreedy merc;
cv::Mat time(images.size(), 2, cv::DataType<double>::type);
for(std::vector<boost::filesystem::path>::iterator iterator = images.begin(); iterator != images.end(); ++iterator) {
cv::Mat mat = cv::imread(iterator->string());
Image<RGBMap> inputImage;
MERCInputImage<RGBMap> input;
inputImage.Resize(mat.cols, mat.rows, false);
for (int i = 0; i < mat.rows; ++i) {
for (int j = 0; j < mat.cols; ++j) {
RGBMap color((int) mat.at<cv::Vec3b>(i, j)[2], (int) mat.at<cv::Vec3b>(i, j)[1], (int) mat.at<cv::Vec3b>(i, j)[0]);
inputImage.Access(j, i) = color;
}
}
input.ReadImage(&inputImage, eightConnected);
timer.restart();
int index = std::distance(images.begin(), iterator);
merc.ClusteringTreeIF(input.nNodes_, input, kernel, sigma*mat.channels(), lambda*1.0*superpixels, superpixels);
time.at<double>(index, 1) = timer.elapsed();
time.at<double>(index, 0) = index + 1;
totalTime += time.at<double>(index, 1);
vector<int> label = MERCOutputImage::DisjointSetToLabel(merc.disjointSet_);
int** labels = new int*[mat.rows];
for (int i = 0; i < mat.rows; ++i) {
labels[i] = new int[mat.cols];
for (int j = 0; j < mat.cols; ++j) {
labels[i][j] = label[j + i*mat.cols];
}
}
Integrity::relabel(labels, mat.rows, mat.cols);
boost::filesystem::path extension = iterator->filename().extension();
int position = iterator->filename().string().find(extension.string());
if (parameters.find("contour") != parameters.end()) {
示例3: mexFunction
void mexFunction(int nlhs, mxArray *plhs[ ],int nrhs, const mxArray *prhs[ ])
{
double lambda,sigma;
int nC,kernel = 0;
int row,col;
int conn8;
double *pLambda,*pSigma,*pNC;
double *data;
double *out;
double *pConn8;
//size_t width,height;
MERCLazyGreedy merc;
mexPrintf("Entropy Rate Superpixel Segmentation Version 0.2!!!\n");
if(!(nrhs==2||nrhs==4||nrhs==5))
{
mexPrintf("Syntax Error!!!\n");
mexPrintf("[labels] = mex_ers(image,nC)\n");
mexPrintf("[labels] = mex_ers(image,nC,lambda,sigma)\n");
mexErrMsgTxt("[labels] = mex_ers(image,nC,lambda,sigma,conn8)\n");
}
//if(nlhs > 1)
//{
// mexErrMsgTxt("Too many output arguments.");
//}
/* Check data type of input argument */
if (!(mxIsDouble(prhs[0])))
{
mexErrMsgTxt("Input argument must be of type double.");
}
//width = mxGetN(prhs[0]);
//height = mxGetM(prhs[0]);
data = mxGetPr(prhs[0]);
if(nrhs==2)
{
pNC = mxGetPr(prhs[1]);
lambda = 0.5;
sigma = 5.0;
conn8 = 1;
}
if(nrhs==4)
{
pNC = mxGetPr(prhs[1]);
pLambda = mxGetPr(prhs[2]);
pSigma = mxGetPr(prhs[3]);
lambda = *pLambda;
sigma = *pSigma;
conn8 = 1;
}
if(nrhs==5)
{
pNC = mxGetPr(prhs[1]);
pLambda = mxGetPr(prhs[2]);
pSigma = mxGetPr(prhs[3]);
pConn8 = mxGetPr(prhs[4]);
lambda = *pLambda;
sigma = *pSigma;
conn8 = (int)(*pConn8);
}
nC = (int)(*pNC);
int nDims = (int)mxGetNumberOfDimensions(prhs[0]);
if(nDims == 3)
{
int width = mxGetN(prhs[0])/nDims;
int height = mxGetM(prhs[0]);
//mexPrintf("Size = ( %d , %d ); Dimension = %d\n",width,height,nDims);
Image<RGBMap> inputImage;
MERCInputImage<RGBMap> input;
// Create Iamge
inputImage.Resize(width,height,false);
// Read the image from MATLAB
for (col=0; col < width; col++)
{
for (row=0; row < height; row++)
{
RGBMap color(
(int)mxGetPr(prhs[0])[row+col*height+0*width*height],
(int)mxGetPr(prhs[0])[row+col*height+1*width*height],
(int)mxGetPr(prhs[0])[row+col*height+2*width*height]);
inputImage.Access(col,row) = color;
}
}
// Read the image for segmentation
input.ReadImage(&inputImage,conn8);
// Entropy rate superpixel segmentation
merc.ClusteringTreeIF(input.nNodes_,input,kernel,sigma*nDims,lambda*1.0*nC,nC);
vector<int> label = MERCOutputImage::DisjointSetToLabel(merc.disjointSet_);
// Allocate memory for the labeled image.
//.........这里部分代码省略.........