[英]Get part of data from cv::Mat
I have a cv::Mat src (type: CV_32F) with size 11000x1085. 我有一个大小为11000x1085的cv :: Mat src(类型:CV_32F)。
Get a row data 获取行数据
cv::Mat dst = src.row();
If I want to get data from column 4 to 1085, I do this way. 如果我想从第4列到第1085页获取数据,我会这样做。
for(int i = 0; i < 11000; i++)
for(int j = 3; j < 1085; j++)
dst.at<double>(i,j-3) = src.at<double>(i,j);
Is there another way to do that faster? 还有另一种方法可以更快地完成吗?
It depends if you want to make a deep copy of the data or not. 这取决于您是否要制作数据的深层副本。 You may want to construct a region of interest (ROI) as described on this helpful tutorial, which describes other methods to work with the cv::Mat to structure your data:
您可能希望构建一个感兴趣的区域(ROI),如本有用的教程所述,该教程描述了使用cv :: Mat构建数据的其他方法:
http://docs.opencv.org/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.html http://docs.opencv.org/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.html
To create a region of interest (ROI) for a rectangle: 要为矩形创建感兴趣区域(ROI):
Mat Dst (src, Rect(3, 0, 11000, 1085) );
If you want copy the data: 如果要复制数据:
Mat Clone = Dst.clone();
你可以使用Mat :: colRange
cv::Mat dst = src.colRange(3, 1085);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.