In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces Python how to achieve simple image scaling and rotation, the article is very detailed, has a certain reference value, interested friends must read it!
1. The image is scaled 1.2. Use the command import cv2# to scale def resize (img, k, inter): res = cv2.resize (img, None, fx=k, fy=k, interpolation=inter) return res
Parameter setting (interpolation):
0: nearest neighbor interpolation
1: bilinear interpolation
2: resampling based on local pixels
3: cubic interpolation based on the neighborhood of 4 pixels.
4: Lanczos interpolation based on 8 pixel neighborhood
Img_row = cv2.imread (ringing Picture4.jpg') cv2.imshow ('origin_picture', img_row) cv2.waitKey (0) inters = [cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_AREA, cv2.INTER_CUBIC, cv2.INTER_LANCZOS4] for inter in inters: res1 = resize (img_row, 2, inter) cv2.imshow (' res1') Res1) cv2.waitKey (0) position = 'pic_resize' +' _'+ str (inter) + '.jpg' cv2.imwrite (position, res1) 1.2. Introduction of principle
Brief introduction to the principles of several methods:
Nearest neighbor interpolation: bilinear interpolation of the pixel values of the nearest neighbor integer coordinate points in the target image: F (xline y) is a binary function, assuming that we know the values of four points f (x _ 0), f (x _ 1 ~ 1), f (x _ 0 ~ 1) and f (x _ 1 ~ 1 ~ y _ 0). These four points determine a rectangle, and we hope to get the function value of any point in the rectangle by interpolation. So we do two linear interpolation in the x direction and one linear interpolation in the y direction. After synthesis, the following formulas are obtained:
Resampling of local pixels: if the scale of the enlarged image is an integer multiple, similar to the nearest neighbor interpolation, if the magnification is not an integer multiple, linear interpolation cubic interpolation will be used: given 1 point, a=x0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.