当前位置:网站首页>Opencv learning notes - remapping
Opencv learning notes - remapping
2022-07-26 03:49:00 【cc_ rong】
Remapping is the process of placing pixels at a certain position in one image to a specified position in another image .
The position of each pixel is expressed by remapping (x, y): g(x, y) = f( h(x, y) )
g() Is the target image ,
f( ) Is the source image ,
h(x, y) It works on (x,y) Mapping method function .
for example :
If there is an image A, Remapping according to this condition : h(x, y) = (A.cols - x, y ), The image will follow x The axis direction is reversed .
remap( ) function According to the specified mapping form , Put source image Remapping geometric transformation , The formula is as follows :
void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode = BORDER_CONSTANT, const Scalar& borderValue = Scalar())Parameters 1, The source image , fill Mat Class object , And it needs to be a single channel 8 Bit or floating point image .
Parameters 2,OutputArray Type of dst, Output image , Need to be the same size and type as the source image .
Parameters 3,InputArray Type of map1, There are two possible representation objects .
Indication point (x,y) The first mapping of .
Express CV_16SC2 , CV_32FC1 or CV_32FC2 Type of X value .
Parameters 4,InputArray Type of map2, There are two possible representation objects , and map2 It's based on map1 To make sure
Represents that kind of object .
if map1 Indication point (x,y) when . This parameter does not represent any value .
Express CV_16UC1 , CV_32FC1 Type of Y value ( Second value ).
Parameters 5, Interpolation method , Previous resize() There's something about... In the function , Be careful ,resize( ) Function
INTER_AREA Interpolation is not supported here , The optional interpolation methods are as follows :
INTER_NEAREST -- Nearest neighbor interpolation
INTER_LINEAR -- Bilinear interpolation ( The default value is )
INTER_CUBIC -- Bicubic spline interpolation ( More than 4×4 Bicubic interpolation in pixel neighborhood )
INTER_LANCZOS4 -- Lanczos interpolation ( More than 8×8 Pixel neighborhood Lanczos interpolation )
Parameters 6, The boundary model , Have default values BORDER_CONSTANT, Represents... In the target image “ outliers (outliers)”
The pixel value of is not modified by this function .
Parameters 7,const Scalar& Type of borderValue, The value used when there is a constant boundary , The default value is Scalar( ),
That is, the default value is 0.
According to the effect :
![]()
Code :
// Variable definitions Mat srcImage, dstImage; Mat map_x, map_y; // Load the original drawing srcImage = imread("E:\\img\\logo6.png", 1); imshow(" The original picture srcImage", srcImage); // Create the same rendering as the original ,x Remapping graph ,y Remapping graph dstImage.create(srcImage.size(), srcImage.type()); map_x.create(srcImage.size(), CV_32FC1); map_y.create(srcImage.size(), CV_32FC1); // Double loop , Go through every pixel , change map_x & map_y Value for (int j = 0; j < srcImage.rows; j++) { for (int i = 0; i < srcImage.cols; i++) { // change map_x & map_y Value . map_x.at<float>(j, i) = static_cast<float>(i); map_y.at<float>(j, i) = static_cast<float>(srcImage.rows - j); } } // Remap remap(srcImage, dstImage, map_x, map_y, INTER_NEAREST, BORDER_CONSTANT, Scalar(0, 0, 0)); imshow(" Mapped image dstImage", dstImage);Sure x Flip 、y Flip 、x y Flip And zoom . Yes map_x perhaps map_y Make changes .
map_x.at<float>(j, i) = static_cast<float>(i);
map_y.at<float>(j, i) = static_cast<float>(srcImage.rows - j);
边栏推荐
猜你喜欢

Supervit for deep learning

涂鸦幻彩产品开发包如何使用

PHP connects to MySQL database, and database connects to static tool classes to simplify the connection.
![[class and object instances in kotlin]](/img/bf/9f3232ef674956b45920b85a947d98.png)
[class and object instances in kotlin]

zk-SNARK:关于私钥、环签名、ZKKSP

cpu和gpu已过时,npu和apu的时代开始

资深报表开发经验总结:明白这一点,没有做不好的报表

General test case writing specification

A large factory developed and tested one, and strangled its neck with a mouse line

Visio:甘特图如何合并单元格?解决方案:覆盖单元格
随机推荐
sersync/lsync实时同步
Why are more and more users of Bing search?
tf.truncated_ Normal() usage
Usage of tf.variable() function in tensorflow
leetcode-462.最少移动次数使数组元素相等
[mathematical modeling - Summary of planning model] | matlab solution
JS Base64 encoding and decoding
Three solutions: when clicking the user to exit the login, press the back button of the browser, and you can still see the previous login page.
在 Istio 服务网格内连接外部 MySQL 数据库
File upload error: current request is not a multipart request
Leetcode-202. happy number
zkEVM:MINA的CEO对zkEVM和L1相关内容的总结
Div setting height does not take effect
Find My技术|物联网资产跟踪市场规模达66亿美元,Find My助力市场发展
ASEMI整流桥GBU1510参数,GBU1510规格,GBU1510封装
安装VMware报错failed to install the hcmon driver
基本折线图:最直观呈现数据的趋势和变化
ZK snark: about private key, ring signature, zkksp
Three ways of redis cluster
2020 AF-RCNN: An anchor-free convolutional neural network for multi-categoriesagricultural pest det

