![](/img/trans.png)
[英]how to fill color into image, by considering small matrix size 3*3 or 6*6? in opencv
[英]Size of Matrix (image) OpenCV
如何獲取圖像的尺寸(寬度和高度)?
我剛剛看到了這個答案,它顯示了兩種方法,並且沒有明確說明它們是否完全等效:
cv::Mat mat; int rows = mat.rows; int cols = mat.cols; cv::Size s = mat.size(); rows = s.height; cols = s.width;
這兩種方法在每種情況下都完全等效嗎?
如果有的話,有什么區別?
OpenCV 版本:4
這兩種方法完全一樣。 我相信這些函數的存在是為了方便,因為有幾種情況下每種方法都有用。
例如,創建一個與另一個相同大小的新cv::Mat
,它更易於編寫和閱讀
cv::Mat new_mat = cv::Mat(old_mat.size(), old_mat.type())
比
cv::Mat new_mat = cv::Mat(old_mat.rows, old_mat.cols, old_mat.type()
此外,我相信更少的函數調用。 使用更方便,更易於閱讀,函數調用更少
for(int i=0; i<old_mat.rows; i++)
for(int j=0; l< old_mat.cols; j++)
比
for(int i=0; i<old_mat.size().width; i++)
for(int j=0; j<old_mat.size().height; j++)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.