当前位置:网站首页>22. pixel remapping
22. pixel remapping
2022-06-26 01:35:00 【Nightmare satiety】
#include <opencv2/opencv.hpp>
#include <iostream>
#include <math.h>
using namespace cv;
Mat src, dst, map_x, map_y;
const char* OUTPUT_TITLE = "remap demo";
int index = 0;
void update_map(void);
int main(int argc, char** argv) {
src = imread("../../source/lena.png");
if (!src.data) {
printf("could not load image...\n");
return -1;
}
char input_win[] = "input image";
namedWindow(input_win, WINDOW_AUTOSIZE);
namedWindow(OUTPUT_TITLE, WINDOW_AUTOSIZE);
imshow(input_win, src);
map_x.create(src.size(), CV_32FC1);
map_y.create(src.size(), CV_32FC1);
int c = 0;
while (true) {
c = waitKey(500);
if ((char)c == 27) {
break;
}
index = c % 4;
update_map();
remap(src, dst, map_x, map_y, INTER_LINEAR, BORDER_CONSTANT, Scalar(0, 255, 255));
imshow(OUTPUT_TITLE, dst);
}
return 0;
}
void update_map(void) {
for (int row = 0; row < src.rows; row++) {
for (int col = 0; col < src.cols; col++) {
switch (index) {
case 0:
if (col > (src.cols * 0.25) && col <= (src.cols*0.75) && row > (src.rows*0.25) && row <= (src.rows*0.75)) {
map_x.at<float>(row, col) = 2 * (col - (src.cols*0.25));
map_y.at<float>(row, col) = 2 * (row - (src.rows*0.25));
}
else {
map_x.at<float>(row, col) = 0;
map_y.at<float>(row, col) = 0;
}
break;
case 1:
map_x.at<float>(row, col) = (src.cols - col - 1);
map_y.at<float>(row, col) = row;
break;
case 2:
map_x.at<float>(row, col) = col;
map_y.at<float>(row, col) = (src.rows - row - 1);
break;
case 3:
map_x.at<float>(row, col) = (src.cols - col - 1);
map_y.at<float>(row, col) = (src.rows - row - 1);
break;
}
}
}
}
边栏推荐
- Comment promouvoir efficacement les produits
- Design and process analysis of anti backflow circuit for MOS transistor
- 数组中的第K个最大元素
- 图文大师印章简易制作
- 走 迷 宫
- shell正则表达式
- 在FreeBSD中安装MySQL数据库
- ETCD数据库源码分析——集群间网络层服务端接口
- The cache page stores the initial parameters after the route jump under the react + router framework
- 多接口调用,使用Promise.all、Promise.race和Promise.any
猜你喜欢

Redis strings command

RT thread project engineering construction and configuration - (Env kconfig)

Multiple interface calls, using promise all、Promise. Race and promise any

多接口调用,使用Promise.all、Promise.race和Promise.any

15 `bs object Node name Node name String` get nested node content

【花雕体验】11 上手ESP32C3

计算机网络知识总结(面试)
![[Excel知识技能] Excel数据类型](/img/f6/e1ebe033d1a2a266ebda00b10098ed.png)
[Excel知识技能] Excel数据类型

Simple making of master seal

新库上线 | CnOpenData中国新房信息数据
随机推荐
数组中的第K个最大元素
Idea configuration
Shell regular expression
Is it safe to log in the stock account on the flush? How to open a stock account in the flush
原生DOM与虚拟DOM
idea配置
Complete review (including syntax) -- MySQL regular expressions
网上开通证券账户安全吗 证券网上开户
经纬度 多点 获取中心点 已解决
2022资料员-通用基础(资料员)考试模拟100题及在线模拟考试
Laravel基础课 路由和MVC——路由
Etcd database source code analysis -- inter cluster network layer server interface
[Excel知识技能] Excel数据类型
新库上线 | CnOpenDataA股上市公司IPO申报发行文本数据
开窍之问答
The kth largest element in the array
Development and monitoring of fusion experiment pulse power supply by LabVIEW
JSON实例(一)
Redis之Strings命令
--SQL of urban cultivation manual -- Chapter 1 basic review