본문 바로가기
카테고리 없음

opencv - warpAffine 함수와 매개변수 의미

by bents 2022. 9. 20.

 

void cv::warpAffine	(	
InputArray 	src,
OutputArray 	dst,
InputArray 	M,
Size 	dsize,
int 	flags = INTER_LINEAR,
int 	borderMode = BORDER_CONSTANT,
const Scalar & 	borderValue = Scalar() 
)		

Python:
cv.warpAffine(	
src, # input image
M,  # transformation matrix
dsize[, # output image size (width, heigth)
dst[, # output instance???????????
flags[, # interpolation - cv2.INTER_AREA, cv2.INTER_CUBIC, etc
borderMode[, # cv2.BORDER_REPLICATE
borderValue]]]]	# BORDER 색깔
) ->	dst

한글 블로그보면 출처를 적어놓지 않음..

 

flags ; 보간법 interpolation algorithm [링크]

Enumerator

INTER_NEAREST 
Python: cv.INTER_NEAREST
nearest neighbor interpolation
INTER_LINEAR 
Python: cv.INTER_LINEAR
bilinear interpolation
INTER_CUBIC 
Python: cv.INTER_CUBIC
bicubic interpolation
INTER_AREA 
Python: cv.INTER_AREA
resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire'-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
INTER_LANCZOS4 
Python: cv.INTER_LANCZOS4
Lanczos interpolation over 8x8 neighborhood
INTER_LINEAR_EXACT 
Python: cv.INTER_LINEAR_EXACT
Bit exact bilinear interpolation
INTER_NEAREST_EXACT 
Python: cv.INTER_NEAREST_EXACT
Bit exact nearest neighbor interpolation. This will produce same results as the nearest neighbor method in PIL, scikit-image or Matlab.
INTER_MAX 
Python: cv.INTER_MAX
mask for interpolation codes
WARP_FILL_OUTLIERS 
Python: cv.WARP_FILL_OUTLIERS
flag, fills all of the destination image pixels. If some of them correspond to outliers in the source image, they are set to zero
WARP_INVERSE_MAP 
Python: cv.WARP_INVERSE_MAP
flag, inverse transformation
For example, linearPolar or logPolar transforms:
  • flag is not set: dst(ρ,ϕ)=src(x,y)
  • flag is set: dst(x,y)=src(ρ,ϕ)
enum  	cv::InterpolationFlags {
  cv::INTER_NEAREST = 0,
  cv::INTER_LINEAR = 1,
  cv::INTER_CUBIC = 2,
  cv::INTER_AREA = 3,
  cv::INTER_LANCZOS4 = 4,
  cv::INTER_LINEAR_EXACT = 5,
  cv::INTER_NEAREST_EXACT = 6,
  cv::INTER_MAX = 7,
  cv::WARP_FILL_OUTLIERS = 8,
  cv::WARP_INVERSE_MAP = 16
}

 

borderMode ; 경계선 픽셀 확장 방식 [링크]

Enumerator

BORDER_CONSTANT 
Python: cv.BORDER_CONSTANT
iiiiii|abcdefgh|iiiiiii with some specified i
BORDER_REPLICATE 
Python: cv.BORDER_REPLICATE
aaaaaa|abcdefgh|hhhhhhh
BORDER_REFLECT 
Python: cv.BORDER_REFLECT
fedcba|abcdefgh|hgfedcb
BORDER_WRAP 
Python: cv.BORDER_WRAP
cdefgh|abcdefgh|abcdefg
BORDER_REFLECT_101 
Python: cv.BORDER_REFLECT_101
gfedcb|abcdefgh|gfedcba
BORDER_TRANSPARENT 
Python: cv.BORDER_TRANSPARENT
uvwxyz|abcdefgh|ijklmno
BORDER_REFLECT101 
Python: cv.BORDER_REFLECT101
same as BORDER_REFLECT_101
BORDER_DEFAULT 
Python: cv.BORDER_DEFAULT
same as BORDER_REFLECT_101
BORDER_ISOLATED 
Python: cv.BORDER_ISOLATED
do not look outside of ROI

 

https://docs.opencv.org/에서 찾아보자!

 

OpenCV documentation index

 

docs.opencv.org