opencv序列图像ROI获取

#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>  
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdlib.h>
#include "opencv/cxcore.h"
#include "opencv/highgui.h"
#include <stdio.h>
#include <iostream>
#include <vector>   
#include <fstream>


#include <iterator>


using namespace std;

using namespace std;

using namespace cv;

//相应的头文件及命名空间要有哦

int main(int argc, char** argv)  


{  
    char filename[100];
    char filename1[100];
    for(int i=28;i<=51;i++)

    {
        sprintf(filename,"F:/fighting/project/data/sundefu-tps/cancer-jpeg/CT_Image_Storage-0%d.jpg",i);// 将图片以数字命名:例如1.jpg 2.jpg等,放入指定文件夹下
        IplImage * src1=cvLoadImage(filename,1);
   // cvSetImageROI(src1,cvRect(100,100,356,156));
    //IplImage* pDest = cvCreateImage(size,pSrc->depth,pSrc->nChannels);//创建目标图像
   CvSize size= cvSize(43,47);//区域大小
   cvSetImageROI(src1,cvRect(238,163,size.width, size.height));//设置源图像ROI,定义矩形左上角坐标和矩形的宽和高来确定一个矩形
   IplImage* pDest = cvCreateImage(size,src1->depth,src1->nChannels);//创建目标图像
   cvCopy(src1,pDest); //复制图像
    cvResetImageROI(pDest);//源图像用完后,清空ROI
    sprintf(filename1,"F:/fighting/project/data/sundefu-tps/cancer-region/%d.jpg",i);// 将图片以数字命名:例如1.jpg 2.jpg等,放入指定文件夹下
    cvSaveImage(filename1,pDest);
    }
    //cvWaitKey();
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值