Python OpenCVã®åºç¤ resieã§ç»åãµã¤ãºãå¤ãã¦ã¿ã
ç»åãµã¤ãºãå¤ããã®ãç°¡åã§ãã
resize
cv2.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]]) â dst¶
ãã£ãã試ãã¦ã¿ã¾ãã
åç´ãªå¦çã§ããã
- ç»åãèªã¿è¾¼ã
- é«ãã¨å¹ ãåå¾ããããã«ãããããååã«ã«ãããµã¤ãºãä½æãã
- cv2,resizeã«å ¥åç»åã¨ãµã¤ãºãè¨å®ãã(ãµã³ãã«ã§ã¯ååã«ãã¦ãã)
- ã¾ãã¯ãµã¤ãºã«ã¯ãå ¥åã®é«ãã¨å¹ ã«å¯¾ããåçãè¨å®ãã(ããã²ã¨ã¤ã®ãµã³ãã«ã¯é«ãã¨å¹ ã2åã«ãã¦ããï¼
çµæ
ãµã³ãã«ãè¼ãã¦ããã¾ãè¦è¦çã«æå³ãç¡ãã®ã§ãããããä»åã¯çµæãµã³ãã«ç¡ãã§ãããã¿ã¾ããã
ç»åã®ç¸®å°ã§ã¯ãæ¹å¼ã«æ°ãã¤ãã
ç»åã縮å°ããå ´åã«ã¯ããã®ç¸®å°æ¹æ³ã«æ°ãã¤ããå¿ è¦ãããã¾ãã
100x100ã®ç»åã50x50ã«ç¸®å°ããå ´åãèãã¾ãããã
ãã1è¡ã«ã¤ãã¦ã100ç»ç´ ã§è¡¨ç¤ºãã¦ãããã®ã50ç»ç´ ã«ç¸®ããããã§ãããã
ãã®ç¸®ãããã¯ã©ããã¾ãããï¼
éå¼ãï¼ã¨ãªãã®ç»ç´ ã¨ã®å¹³åï¼å¹³åãªã縦横ã®é¢ä¿ã¯ï¼
ãªã©ãèãããã¨ã¯æå¤ã¨ããããããã¾ãã
ã¾ããé¸æãã縮å°æ¹å¼ã«ãããåºåã®ç»åã¯å¤ãã£ã¦ãã¦ãã¾ããã¨ã«ãªãã¾ãã
Methodãç¨æããã¦ãã¾ã
resizeã«ã¯ããã®ç¸®å°ã®æ¹å¼ãæå®ãããã¨ãã§ãã¾ãããã¡ããè¦ã¦ã¿ã¾ããã
interpolation â interpolation method:
INTER_NEAREST - a nearest-neighbor interpolation
INTER_LINEAR - a bilinear interpolation (used by default)
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_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood
ããã©ã«ãã¯LINERã®ããã§ããã
ãã®ãããã¯å°ãç解ãæ·±ãã¦ãããã»ããããããããã¾ããã 以ä¸ã®ãµã¤ãã«è©³ãã解説ãã¦ããã¾ããããããã¨ããããã¾ãã
画素の補間(Nearest neighbor,Bilinear,Bicubic) 画像処理ソリューション
to shrink an image, it will generally look best with CV_INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with CV_INTER_CUBIC (slow) or CV_INTER_LINEAR (faster but still looks OK).
ç»åã®ç¸®å°ã«ã¯INTER_AREAãæ¡å¤§ã«ã¯INTER_CUBIC(å¦çé ã)ãã¾ãã¯INTER_LINER(éãã¦è¦ãç®ããã)ã使ã£ã¦ããã¨ãããã¨ã¿ããã§ãã
ãã£ã±ããµã³ãã«
å ¨ããµã³ãã«ããªãã®ãå¯ããã®ã§ãã¡ãã£ã¨ä½ã£ã¦ã¿ã¾ãã ä¸è¨ã®ãµã³ãã«ã³ã¼ãã§ãfx=2 fy=1ã«è¨å®ãã¾ãããããããã«å¹ ã ãã2åã«ãªãã¨ãããã¨ã§ããã
æè¬
åèã«ããã¦ããã ãã¾ããããããã¨ããããã¾ããã