mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #24621 from chacha21:remap_relative
First proposal of cv::remap with relative displacement field (#24603) #24621 Implements #24603 Currently, `remap()` is applied as `dst(x, y) <- src(mapX(x, y), mapY(x, y))` It means that the maps must be filled with absolute coordinates. However, if one wants to remap something according to a displacement field ("warp"), the operation should be `dst(x, y) <- src(x+displacementX(x, y), y+displacementY(x, y))` It is trivial to build a mapping from a displacement field, but it is an undesirable overhead for CPU and memory. This PR implements the feature as an experimental option, through the optional flag WARP_RELATIVE_MAP than can be ORed to the interpolation mode. Since the xy maps might be const, there is no attempt to add the coordinate offset to those maps, and everything is postponed on-the-fly to the very last coordinate computation before fetching `src`. Interestingly, this let `cv::convertMaps()` unchanged since the fractional part of interpolation does not care of the integer coordinate offset. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [X] There is a reference to the original bug report and related work - [X] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -275,7 +275,8 @@ enum InterpolationFlags{
|
||||
- flag is __not__ set: \f$dst( \rho , \phi ) = src(x,y)\f$
|
||||
- flag is set: \f$dst(x,y) = src( \rho , \phi )\f$
|
||||
*/
|
||||
WARP_INVERSE_MAP = 16
|
||||
WARP_INVERSE_MAP = 16,
|
||||
WARP_RELATIVE_MAP = 32
|
||||
};
|
||||
|
||||
/** \brief Specify the polar mapping mode
|
||||
@@ -2490,6 +2491,7 @@ CV_EXPORTS_W void warpPerspective( InputArray src, OutputArray dst,
|
||||
The function remap transforms the source image using the specified map:
|
||||
|
||||
\f[\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\f]
|
||||
\f[\texttt{dst} (x,y) = \texttt{src} (x+map_x(x,y),y+map_y(x,y))\f] with WARP_RELATIVE_MAP
|
||||
|
||||
where values of pixels with non-integer coordinates are computed using one of available
|
||||
interpolation methods. \f$map_x\f$ and \f$map_y\f$ can be encoded as separate floating-point maps
|
||||
@@ -2509,7 +2511,9 @@ representation to fixed-point for speed.
|
||||
@param map2 The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map
|
||||
if map1 is (x,y) points), respectively.
|
||||
@param interpolation Interpolation method (see #InterpolationFlags). The methods #INTER_AREA
|
||||
and #INTER_LINEAR_EXACT are not supported by this function.
|
||||
#INTER_LINEAR_EXACT and #INTER_NEAREST_EXACT are not supported by this function.
|
||||
The extra flag WARP_RELATIVE_MAP that can be ORed to the interpolation method
|
||||
(e.g. INTER_LINEAR | WARP_RELATIVE_MAP)
|
||||
@param borderMode Pixel extrapolation method (see #BorderTypes). When
|
||||
borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image that
|
||||
corresponds to the "outliers" in the source image are not modified by the function.
|
||||
|
||||
@@ -376,8 +376,9 @@ enum
|
||||
/** ... and other image warping flags */
|
||||
enum
|
||||
{
|
||||
CV_WARP_FILL_OUTLIERS =8,
|
||||
CV_WARP_INVERSE_MAP =16
|
||||
CV_WARP_FILL_OUTLIERS = 8,
|
||||
CV_WARP_INVERSE_MAP = 16,
|
||||
CV_WARP_RELATIVE_MAP = 32
|
||||
};
|
||||
|
||||
/** Shapes of a structuring element for morphological operations
|
||||
|
||||
Reference in New Issue
Block a user