In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail the example analysis of geometric operations in Python dealing with digital images. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Translation
# define translation matrix, need to be float32 type of numpy # x axis translation 50, y axis translation 80, 2x 3 matrix M = np.array ([[1,0,50], [0,1,80]], dtype=np.float32) # translate new_image = cv2.warpAffine (image, M, (w, h), borderValue= (0,0,0)) by affine transformation
Mirror image
Horizontal mirroring
# Flipped Horizontally horizontal Flip Horizontal = cv2.flip (image, 1)
Vertical mirroring
# Flipped Vertically Vertical Flip Vertical = cv2.flip (image, 0)
Rotation takes the upper left corner of the image as the center of rotation
# define rotation matrix, 2x3M = np.array ([np.cos (Beta), np.sin (Beta), 0], [- np.sin (Beta), np.cos (Beta), 0], dtype=np.float32) # realize rotation new_image = cv2.warpAffine (image, M, (w, h)) by affine transformation
Take the center of the image as the rotation center # define the rotation matrix, this time use the function cv2.getRotationMatrix2D (), where the first parameter is the center point of the rotation, the second is the rotation angle, and the third is the scaling ratio M = cv2.getRotationMatrix2D ((hash 2) print (M) # using affine transformation to achieve rotation new_image = cv2.warpAffine (image, M, (w, h), borderMode=cv2.BORDER_DEFAULT)
Scalin
New_image = cv2.resize (image, (0,0), fx=3, fy=3, interpolation=cv2.INTER_NEAREST)
Interpolation algorithm nearest neighbor interpolation algorithm cv2.INTER_NEAREST bilinear interpolation algorithm cv2.INTER_LINEAR cubic interpolation cv2.INTER_CUBIC on "geometric operations in Python processing digital image example analysis" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
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.