Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python Code to realize High Resolution Image Navigation

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about how to use Python code to achieve high-resolution image navigation, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

In the process of project development, we often encounter the problem of viewing image details. At this time, we usually scroll the pulley to enlarge the image, or use the built-in amplifier function of the computer to view it. As shown in the following figure, it is the effect that I use the high-definition image navigation function of Altium Designer software to view the details of PCB:

Import image function

The image import function is based on the Windows command window. Users can import image information by calling the Python file in the command window. The input instructions and effects are as follows:

The implementation code is as follows:

If len (sys.argv) > 1: # Import fn = cv.samples.findFile (sys.argv [1]) print ('loading% s...'% fn) img = cv.imread (fn) if img is None: print ('Failed to load fn:', fn) sys.exit (1) according to the image entered in the console

Image downsampling function

The imported image is downsampled to form a reduced overall effect image, which is convenient to compare with the super-resolution enlarged image, and the effect is as follows:

The implementation code is as follows:

Small = imgfor _ i in range (3): # Image desampling small = cv.pyrDown (small)

High resolution navigation function

Finally, the super-resolution image navigation function is realized. Here, a mouse event is created, and the super-resolution image moves with the mouse to achieve the navigation effect. The effect is as follows:

The implementation code is as follows:

# Mouse response event def onmouse (event, x, y, flags, param): h, _ w = img.shape [: 2] H2, _ W1 = small.shape [: 2] x, y = 1.0*x*h/h2, 1.0*y*h/h2 zoom = cv.getRectSubPix (img, (800,600), (x, x, y) 0.5) cv.imshow ('zoom', zoom)

Image display function

Finally, just display the image, and the implementation code is as follows:

Cv.imshow ('preview', small) cv.setMouseCallback (' preview', onmouse) cv.waitKey () after reading the above, do you have any further understanding of how to use Python code to achieve high-resolution image navigation? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report