概述
IplImage * c_allImage =cvCloneImage(image);
cv::Matmtx(c_allImage, 0);
//画矩形的上面的边,宽度为5
for(int j = origin_upToup; j < origin_upToup + 5; j++)
for(inti = origin_leftToleft; i < origin_leftToleft + origin_width; i++)
for(int n = 0;n < mtx.channels(); n++){
if(n == 0) mtx.at<uchar>(origin_upToup,i * mtx.channels() + n) = 255; //取得像素或者赋值
else
mtx.at<uchar>(j,i* mtx.channels() + n) = 0;
}
//画矩形的下面的边,宽度为5
for(int j = origin_upToup; j < origin_upToup + 5; j++)
for(inti = origin_leftToleft; i < origin_leftToleft + origin_width; i++)
for(int n = 0; n < mtx.channels(); n++){
if (n == 0)mtx.at<uchar>(origin_upToup,i * mtx.channels() + n) = 255; //取得像素或者赋值
else
mtx.at<uchar>((j + origin_height),i *mtx.channels() + n) = 0;
}
//画矩形的左面的边,宽度为5
for(int j = origin_leftToleft; j < origin_leftToleft + 5; j++)
for(inti = origin_upToup; i < origin_upToup + origin_height; i++)
for(int n = 0; n < mtx.channels(); n++){
if (n == 0) mtx.at<uchar>(i,origin_leftToleft* mtx.channels() + n) = 255; //取得像素或者赋值
else
mtx.at<uchar>(i,j * mtx.channels() + n)= 0;
}
//画矩形的右面的边,宽度为5
for(int j = origin_leftToleft; j > origin_leftToleft - 5; j--)
for(inti = origin_upToup; i < origin_upToup + origin_height; i++)
for(int n = 0; n < mtx.channels(); n++){
if (n == 0)mtx.at<uchar>(i,(origin_leftToleft + origin_width) * mtx.channels() + n)= 255; //取得像素或者赋值
else
mtx.at<uchar>(i,(j + origin_width) *mtx.channels() + n) = 0;
}
*c_allImage= IplImage(mtx);
最后
以上就是殷勤苗条为你收集整理的在图像上画矩形 opencv的全部内容,希望文章能够帮你解决在图像上画矩形 opencv所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复