There are some windows taskbar so image can’t display full screen I think use 90% of scree size is good to display. Newimg = cv2.resize(oriimg,(int(newX),int(newY)))Ĭv2.imshow("fit image to screen by CV2",newimg) NewX,newY = oriimg.shape*imgScale, oriimg.shape*imgScale Oriimg = cv2.imread(filename,cv2.CV_LOAD_IMAGE_COLOR) Screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1) this code will detect display size and resize your image to fit on it. With this article at OpenGenus, you must have the complete idea of how to resize an image in Python using OpenCV.OpenCV can display image but if your image bigger than your screen or your display window you can’t see all your image. Image = cv2.imread("image.jpeg", mode='RGB') Image resizing with different Interpolation methods. Image resizing with a custom Width and Height. Reading an Image using OpenCV imread () function. Hence, the image is not being scaled to full screen as the window. One needs to try by experimentation.Ĭomplete Python code to resize an image: import cv2 Several methods are available in OpenCV, the choice typically depends on the particular application. cv2.WINDOWNORMAL fits window to full screen, but it doesnt support image resize. Downscaling can be done by passing the factor. The best interpolation method will depend on the image. We’ll use the resize function to scale an image by multiplying the scale factor with the original image dimension and return the scaled image.
0 Comments
Leave a Reply. |