OpenCV学习笔记8_ShowROI_显示感兴趣区域
2013-05-10 15:02
453 查看
ShowROI_显示感兴趣区域
ShowROI.c 用复制替换图层,替换出自己感兴趣的ROI
ShowROI.c 改进版,用指针偏移,像素替换
ShowROI.c 用复制替换图层,替换出自己感兴趣的ROI
#include "stdafx.h" #include "cv.h" #include "highgui.h" #include "cxcore.h" int main() { IplImage* img; img = cvLoadImage("E:\\TempDataForDebug\\tomato1.jpg"); IplImage* sub_image = cvLoadImage("E:\\TempDataForDebug\\bee.jpg"); CvRect rect; rect.x = 400; rect.y = 23; rect.width = sub_image->width; rect.height = sub_image->height; cvSetImageROI(img, rect); cvCopy(sub_image, img); cvResetImageROI(img);
cvNamedWindow("sub"); cvShowImage("sub",sub_image);
cvNamedWindow("1"); cvShowImage("1",img); cvWaitKey(0); return 0; }
ShowROI.c 改进版,用指针偏移,像素替换
#include "stdafx.h" #include "cv.h" #include "highgui.h" #include "cxcore.h" int main() { IplImage* img; img = cvLoadImage("E:\\TempDataForDebug\\tomato1.jpg"); IplImage* sub_image = cvLoadImage("E:\\TempDataForDebug\\bee.jpg"); CvRect rect; rect.x = 400; rect.y = 23; rect.width = sub_image->width; rect.height = sub_image->height; int y,x; for (y = 0; y<sub_image->height; y++) { unsigned char* subImgData = (unsigned char*)(sub_image->imageData+y*sub_image->widthStep); unsigned char* bigImgData = (unsigned char*)(img->imageData+(y+rect.y)*img->widthStep); for (x = 0; x<sub_image->width; x++) { bigImgData[3*(x+rect.x) + 0] = subImgData[3*x + 0]; bigImgData[3*(x+rect.x) + 1] = subImgData[3*x + 1]; bigImgData[3*(x+rect.x) + 2] = subImgData[3*x + 2]; } } cvNamedWindow("sub"); cvShowImage("sub",sub_image); cvNamedWindow("1"); cvShowImage("1",img); cvWaitKey(0); return 0; }
相关文章推荐
- 【OpenCV学习笔记】【编程实例】四(获取一个或多个感兴趣区域)
- 【OpenCV学习笔记】【函数学习】十九(感兴趣区域)
- OPENCV学习笔记1-7_定义感兴趣区域
- OpenCV 2 学习笔记(26): 自选区域进行模板匹配
- 【Ubuntu+OpenCV】ubuntu/linux环境下,运用opencv实现图像的读入、显示--学习笔记【1】
- Opencv2系列学习笔记10(提取连通区域轮廓)
- opencv学习笔记----浅析图像的载入,显示和输出
- 【opencv学习笔记】SetImageROI函数设置ROI区域的作用及用法
- opencv学习笔记11 在图片中添加文字,点击鼠标显示位置坐标
- OpenCV 2 学习笔记(27): 自选区域进行GrabCut图像分割
- OpenCV学习笔记(15)使用OpenGL显示双目视觉三维重构效果 (转)
- OpenCV 学习笔记(1)显示图像
- OpenCV学习笔记(5)在单个窗口中显示多个视频子窗口
- OpenCV学习笔记(9)利用MFC的Picture控件显示图像+播放视频和捕获摄像头画面
- 【OpenCV学习笔记 010】提取直线、轮廓及连通区域
- opencv开发笔记(九):利用addWeighted实现感兴趣区域图像混合
- 像素临近区域、颜色通道、ROI区域的访问---opencv.2学习笔记2
- Opencv学习笔记-显示图像
- OpenCV学习笔记(5)在单个窗口中显示多个视频子窗口
- Kinect开发学习笔记之(四)提取颜色数据并用OpenCV显示(转)