/**
* @file SURF_Homography
* @brief SURF detector + descriptor + FLANN Matcher + FindHomography
* @author A. Huaman
*/
#include <stdio.h>
#include <iostream>
#include <cv.h>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
#define KCV_ImageRow(ptr, step, row)\
((ptr)+(step)* (row))
static void icvCircShiftUD_(const uchar* sptr_, int sstep, uchar* dptr_, int dstep, int w, int h, int yShift)
{
yShift = (h + yShift % h) % h;
if (yShift == 0) return;
sstep /= sizeof(sptr_[0]);
dstep /= sizeof(dptr_[0]);
const uchar* sptr = KCV_ImageRow(sptr_, sstep, h - yShift);
uchar* dptr = dptr_;
w *= sizeof(sptr[0]);
for (int i = 0; i < yShift; ++i, sptr += sstep, dptr += dstep)
{
memcpy(dptr, sptr, 3*w);//3*w,移位的是3通道图像;w,移位的是单通道图像
}
sptr = sptr_;
for (int i = yShift; i < h; ++i, sptr += sstep, dptr += dstep)
{
memcpy(dptr, sptr, 3*w);
}
}
int main()
{
IplImage* src = cvLoadImage("images\\lena.jpg",1);//1 代表导入彩色3通道图像,0代表导入黑白单通道图像
cvShowImage("src", src);
const uchar* sptr = (uchar*)(src->imageData);
int w = src->width;
int h = src->height;
int sstep = src->widthStep;
IplImage *dst = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 3);//3代表3通道图像,1代表单通道图像
uchar* dptr = (uchar*)(dst->imageData);
int dstep = dst->widthStep;
int yShift = 0;
CvRNG rng;
rng = cvRNG(cvGetTickCount());
for (int i = 0; i < 1000; i++)//产生1000幅循环移位图像
{
printf("%d\n", cvRandInt(&rng) % h);//出来的是0~h的正整数
yShift = cvRandInt(&rng) % h;
icvCircShiftUD_(sptr, sstep, dptr, dstep, w, h, yShift);
char filename[255];
sprintf_s(filename, "images\\dst\\dst%d.jpg", i);
cvSaveImage(filename, dst);
}
cvReleaseImage(&src);
cvReleaseImage(&dst);
cvWaitKey(-1);
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
CircShift.zip (11个子文件)
CircShift
CircShift.sln 1KB
OpenCV.props 2KB
x64
Debug
Release
CircShift
CircShift.vcxproj.filters 945B
images
lena.jpg 90KB
dst
x64
Debug
CircShift.log 3B
CircShift.Build.CppClean.log 739B
CircShift.tlog
Release
CircShift.log 3B
CircShift.Build.CppClean.log 661B
CircShift.tlog
main.cpp 2KB
CircShift.vcxproj 6KB
CircShift.v12.suo 450KB
共 11 条
- 1
资源评论
LICHUNLI1022
- 粉丝: 66
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- UIGF_200852355_202404242026.json
- 基于STM32单片机的智能停车场设计源码+全部资料.zip
- 基于Python+Opencv+keras的实时手势识别系统+源码+文档(期末大作业&课程设计&项目开发)
- 基于LabView+MATLAB的说话人识别系统.zip
- 基于树莓派+OpenCV+Python语言的人脸识别+源码+开发文档(毕业设计&课程设计&项目开发)
- 前端vue框架,后端ssm+springboot框架,网站开发.zip
- 基于springboot的快速开发框架.zip
- 基于springboot的分布式权限管理系统,易读易懂、界面简洁美观.zip
- 基于SpringBoot Mybatis-Plus TypeScript的微服务多租户SaaS管理快速开发框架 .zip
- 论文复现:QA-GNN: Reasoning with Language Models and Knowledge
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功