OpenCV图像旋转,指定填充背景颜色边界颜色
OpenCV圖像旋轉,指定填充背景顏色邊界顏色
OpenCV與圖像旋轉有關的函數: (1)warpAffine函數| void cv::warpAffine | ( | InputArray? | src, |
| ? | ? | OutputArray? | dst, |
| ? | ? | InputArray? | M, |
| ? | ? | Size? | dsize, |
| ? | ? | int? | flags?=?INTER_LINEAR, |
| ? | ? | int? | borderMode?=?BORDER_CONSTANT, |
| ? | ? | const?Scalar?&? | borderValue?=?Scalar()? |
| ? | ) | ? | ? |
Applies an affine transformation to an image.
The function warpAffine transforms the source image using the specified matrix:
dst(x,y)=src(M11x+M12y+M13,M21x+M22y+M23)when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with?cv::invertAffineTransform?and then put in the formula above instead of M. The function cannot operate in-place.
Parameters| src | input image. |
| dst | output image that has the size dsize and the same type as src . |
| M | 2×3?transformation matrix. |
| dsize | size of the output image. |
| flags | combination of interpolation methods (see?cv::InterpolationFlags) and the optional flag WARP_INVERSE_MAP that means that M is the inverse transformation (?dst→src?). |
| borderMode | pixel extrapolation method (see?cv::BorderTypes); when borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function. |
| borderValue | value used in case of a constant border; by default, it is 0. |
? InputArray src:輸入的圖像C++: void warpAffine(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, intborderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
? 第1個參數:OutputArray dst:輸出的圖像?
? 第2個參數:InputArray M:透視變換的矩陣
? 第3個參數:Size dsize:輸出圖像的大小
? 第4個參數:int flags=INTER_LINEAR:輸出圖像的插值方法,可以為
? ? ? ? ? ? INTER_LINEAR 線性插值;
? ? ? ? ? ? INTER_NEAREST 最近鄰插值;
? ? ? ? ? ? INTER_AREA 區域插值
? ? ? ? ? ? INTER_CUBIC 三次條樣插值
? ? ? ? ? ? CV_WARP_INVERSE_MAP:指定 matrix 是輸出圖像到輸入圖像的反變換,因此可以直接用來做象素插值。否則, 函數從 map_matrix 得到反變換。
? ? ? ? ? ? CV_WARP_FILL_OUTLIERS:填充所有縮小圖像的象素。如果部分象素落在輸入圖像的邊界外,那么它們的值設定為 fillval(fillval
用來填充邊界外面的值).
? 第5個參數:int borderMode:圖像邊界的處理方式,默認是BORDER_CONSTANT(即指定常數值填充) ,實質上,邊界處理類型,該枚舉型還有:
| BORDER_CONSTANT? | iiiiii|abcdefgh|iiiiiii?with some specified?i(指定常數填充) |
| BORDER_REPLICATE? | aaaaaa|abcdefgh|hhhhhhh(復制邊緣像素填充) |
| BORDER_REFLECT? | fedcba|abcdefgh|hgfedcb(反射復制邊界像素) |
| BORDER_WRAP? | cdefgh|abcdefgh|abcdefg |
| BORDER_REFLECT_101? | gfedcb|abcdefgh|gfedcba(對稱填充,也就是以最邊緣像素為軸) |
| BORDER_TRANSPARENT? | uvwxyz|absdefgh|ijklmno |
| BORDER_REFLECT101? | same as BORDER_REFLECT_101 |
| BORDER_DEFAULT? | same as BORDER_REFLECT_101 |
| BORDER_ISOLATED? | do not look outside of ROI |
【尊重原創,轉載請注明出處】 http://blog.csdn.net/guyuealian/article/details/77993410
總結
以上是生活随笔為你收集整理的OpenCV图像旋转,指定填充背景颜色边界颜色的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C++读取文件夹中所有文件的路径,包含子
- 下一篇: OpenCV中cvAdds和cvAdd中