本文整理汇总了C++中cv::Mat::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat::resize方法的具体用法?C++ Mat::resize怎么用?C++ Mat::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::Mat
的用法示例。
在下文中一共展示了Mat::resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addResponsesForImage
void learndictionary::addResponsesForImage(const cv::Mat& img, cv::Mat& responses)
{
cv::Mat* filterResponse = FilterBank::getInstance().apply(img);
int currentRow = responses.rows;
//responses.resize(img.rows * img.cols); //resize response matrix for new responses - not correct
//TODO: done
//calculate the responses for the image
//for a mxn image you get m*n responses.
// resize the image for m*n new ADDITIONAL responses, each row is one response
responses.resize(responses.rows + img.rows * img.cols);
for(int row = 0; row < img.rows; row++)
{
for(int col = 0; col < img.cols; col++)
{
for(int i = 0; i < responses.cols; i++)
{
int responseRow = currentRow + row * img.cols + col;
responses.at<float>(responseRow, i) = filterResponse[i].at<double>(row, col);
}
}
}
}
示例2: _removeRowsNonContinuous
void Mat::_removeRowsNonContinuous(cv::Mat &m,
const std::vector<unsigned int> &rows)
{
// always preserve the order of the rest of rows
// remove rows in descending order, grouping when possible
int end_row = m.rows;
int i_idx = (int)rows.size() - 1;
while(i_idx >= 0)
{
int j_idx = i_idx - 1;
while(j_idx >= 0 && ((int)(rows[i_idx] - rows[j_idx]) == i_idx - j_idx))
{
j_idx--;
}
//data.erase(data.begin() + indices[j_idx + 1],
// data.begin() + indices[i_idx] + 1);
// ==
//std::copy( m.ptr<T>(rows[i_idx]+1), m.ptr<T>(end_row),
// m.ptr<T>(rows[j_idx + 1]) );
m.rowRange(rows[j_idx+1], rows[j_idx+1] + end_row-rows[i_idx]-1) =
m.rowRange(rows[i_idx]+1, end_row) * 1;
end_row -= rows[i_idx] - rows[j_idx+1] + 1;
i_idx = j_idx;
}
// remove last rows
m.resize(end_row);
}