Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions modules/imgproc/include/opencv2/imgproc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions modules/imgproc/include/opencv2/imgproc/types_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions modules/imgproc/perf/perf_warp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ enum{HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH};

CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE)
CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR)
CV_ENUM(InterTypeExtended, INTER_NEAREST, INTER_LINEAR, WARP_RELATIVE_MAP)
CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH)

typedef TestBaseWithParam< tuple<Size, InterType, BorderMode> > TestWarpAffine;
typedef TestBaseWithParam< tuple<Size, InterType, BorderMode> > TestWarpPerspective;
typedef TestBaseWithParam< tuple<Size, InterType, BorderMode, MatType> > TestWarpPerspectiveNear_t;
typedef TestBaseWithParam< tuple<MatType, Size, InterType, BorderMode, RemapMode> > TestRemap;
typedef TestBaseWithParam< tuple<MatType, Size, InterTypeExtended, BorderMode, RemapMode> > TestRemap;

void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode );
void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode, bool relative = false );

PERF_TEST_P( TestWarpAffine, WarpAffine,
Combine(
Expand Down Expand Up @@ -204,7 +205,7 @@ PERF_TEST_P( TestRemap, remap,
Combine(
Values( CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1 ),
Values( szVGA, sz1080p ),
InterType::all(),
InterTypeExtended::all(),
BorderMode::all(),
RemapMode::all()
)
Expand All @@ -224,7 +225,7 @@ PERF_TEST_P( TestRemap, remap,

declare.in(source, WARMUP_RNG);

update_map(source, map_x, map_y, remapMode);
update_map(source, map_x, map_y, remapMode, ((interpolationType & WARP_RELATIVE_MAP) != 0));

TEST_CYCLE()
{
Expand All @@ -234,7 +235,7 @@ PERF_TEST_P( TestRemap, remap,
SANITY_CHECK_NOTHING();
}

void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode )
void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode, bool relative )
{
for( int j = 0; j < src.rows; j++ )
{
Expand Down Expand Up @@ -267,6 +268,12 @@ void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode )
map_y.at<float>(j,i) = static_cast<float>(src.rows - j) ;
break;
} // end of switch

if( relative )
{
map_x.at<float>(j,i) -= static_cast<float>(i);
map_y.at<float>(j,i) -= static_cast<float>(j);
}
}
}
}
Expand Down
Loading