国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Python and OpenCV efficiently extract two circular areas in 9000x7000 pixel images
Home Backend Development Python Tutorial How to extract two circular areas from a 9000x7000 pixel image using Python and OpenCV?

How to extract two circular areas from a 9000x7000 pixel image using Python and OpenCV?

Apr 01, 2025 pm 09:42 PM
python windows ai red

How to extract two circular areas from a 9000x7000 pixel image using Python and OpenCV?

Python and OpenCV efficiently extract two circular areas in 9000x7000 pixel images

Processing ultra-high resolution images (such as 9000x7000 pixels) and extracting specific shapes (such as circles) from them is a common challenge in image processing and computer vision. This article provides a solution using Python and OpenCV libraries to efficiently and accurately extract target circular areas.

The problem with the existing code is that there are too many circles detected and it is impossible to accurately select the two circle areas required. For improvement, we will adopt the following strategies:

  1. Image Preprocessing: Scaling and Noise Reduction : First, to improve processing efficiency, we reduce the original image to the right size. At the same time, a Gaussian blur filter is applied to reduce image noise, thereby improving the accuracy of circular detection.
 import cv2
import numpy as np

image_path = r"c:\users\17607\desktop\smls pictures\pic_20231122151507973.bmp"

# Read image img = cv2.imread(image_path)

# Zoom the image (adjust the zoom ratio according to the actual situation)
scale_percent = 10 # Scale to 1/10 of the original image
width = int(img.shape[1] / scale_percent)
height = int(img.shape[0] / scale_percent)
dim = (width, height)
resized_img = cv2.resize(img, dim, interpolation=cv2.INTER_AREA)

# grayscale conversion gray = cv2.cvtColor(resized_img, cv2.COLOR_BGR2GRAY)

# GaussianBlurred = cv2.GaussianBlur(gray, (5, 5), 0)
  1. Edge detection: Canny algorithm : Use the Canny edge detection algorithm to extract image edge information and prepare for subsequent circular detection.
 # Canny edge detection edges = cv2.Canny(blurred, 50, 150)
  1. Circle detection: Hough Transform : Use Hough Circle transformation to detect circles in images. The key is parameter adjustments to ensure that only the two circles we need are detected. Here we filter according to the radius of the circle and select the two largest circles.
 # HoughCircle Transform Circles = cv2.HoughCircles(edges, cv2.HOUGH_GRADIENT, 1, 40, param1=50, param2=30, minRadius=0, maxRadius=0)

If circles is not None:
    circles = np.uint16(np.around(circles))
    # Select two largest circles = circles[0, :]
    circles = circles[np.argsort(circles[:, 2])[::-1][:2]] # Select two circles with the largest radius for i in circles:
        center_x, center_y, radius = i
        # Draw circle cv2.circle(resized_img, (center_x, center_y), radius, (0, 0, 255), 2)
        cv2.circle(resized_img, (center_x, center_y), 2, (255, 0, 0), 3)

    cv2.imshow("Detected Circles", resized_img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

Through the above steps, we can effectively extract the two largest circular regions from high-resolution images and verify them by visualization results. It should be noted that the parameters of scale_percent and Hough transformation need to be adjusted according to the actual image to achieve the best detection effect. If two circles are of similar size, a more refined choice may be required based on the center coordinates or other features.

The above is the detailed content of How to extract two circular areas from a 9000x7000 pixel image using Python and OpenCV?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The flow of funds on the chain is exposed: What new tokens are being bet on by Clever Money? The flow of funds on the chain is exposed: What new tokens are being bet on by Clever Money? Jul 16, 2025 am 10:15 AM

Ordinary investors can discover potential tokens by tracking "smart money", which are high-profit addresses, and paying attention to their trends can provide leading indicators. 1. Use tools such as Nansen and Arkham Intelligence to analyze the data on the chain to view the buying and holdings of smart money; 2. Use Dune Analytics to obtain community-created dashboards to monitor the flow of funds; 3. Follow platforms such as Lookonchain to obtain real-time intelligence. Recently, Cangming Money is planning to re-polize LRT track, DePIN project, modular ecosystem and RWA protocol. For example, a certain LRT protocol has obtained a large amount of early deposits, a certain DePIN project has been accumulated continuously, a certain game public chain has been supported by the industry treasury, and a certain RWA protocol has attracted institutions to enter.

How to Install PHP on Windows How to Install PHP on Windows Jul 15, 2025 am 02:46 AM

The key steps to install PHP on Windows include: 1. Download the appropriate PHP version and decompress it. It is recommended to use ThreadSafe version with Apache or NonThreadSafe version with Nginx; 2. Configure the php.ini file and rename php.ini-development or php.ini-production to php.ini; 3. Add the PHP path to the system environment variable Path for command line use; 4. Test whether PHP is installed successfully, execute php-v through the command line and run the built-in server to test the parsing capabilities; 5. If you use Apache, you need to configure P in httpd.conf

Which is better, DAI or USDC?_Is DAI suitable for long-term holding? Which is better, DAI or USDC?_Is DAI suitable for long-term holding? Jul 15, 2025 pm 11:18 PM

Is DAI suitable for long-term holding? The answer depends on individual needs and risk preferences. 1. DAI is a decentralized stablecoin, generated by excessive collateral for crypto assets, suitable for users who pursue censorship resistance and transparency; 2. Its stability is slightly inferior to USDC, and may experience slight deansal due to collateral fluctuations; 3. Applicable to lending, pledge and governance scenarios in the DeFi ecosystem; 4. Pay attention to the upgrade and governance risks of MakerDAO system. If you pursue high stability and compliance guarantees, it is recommended to choose USDC; if you attach importance to the concept of decentralization and actively participate in DeFi applications, DAI has long-term value. The combination of the two can also improve the security and flexibility of asset allocation.

Who is suitable for stablecoin DAI_ Analysis of decentralized stablecoin usage scenarios Who is suitable for stablecoin DAI_ Analysis of decentralized stablecoin usage scenarios Jul 15, 2025 pm 11:27 PM

DAI is suitable for users who attach importance to the concept of decentralization, actively participate in the DeFi ecosystem, need cross-chain asset liquidity, and pursue asset transparency and autonomy. 1. Supporters of the decentralization concept trust smart contracts and community governance; 2. DeFi users can be used for lending, pledge, and liquidity mining; 3. Cross-chain users can achieve flexible transfer of multi-chain assets; 4. Governance participants can influence system decisions through voting. Its main scenarios include decentralized lending, asset hedging, liquidity mining, cross-border payments and community governance. At the same time, it is necessary to pay attention to system risks, mortgage fluctuations risks and technical threshold issues.

Python for loop range Python for loop range Jul 14, 2025 am 02:47 AM

In Python, using a for loop with the range() function is a common way to control the number of loops. 1. Use when you know the number of loops or need to access elements by index; 2. Range(stop) from 0 to stop-1, range(start,stop) from start to stop-1, range(start,stop) adds step size; 3. Note that range does not contain the end value, and returns iterable objects instead of lists in Python 3; 4. You can convert to a list through list(range()), and use negative step size in reverse order.

The role of Ethereum smart contracts The role of Ethereum smart contracts Jul 15, 2025 pm 09:18 PM

The role of Ethereum smart contract is to realize decentralized, automated and transparent protocol execution. Its core functions include: 1. As the core logic layer of DApp, it supports token issuance, DeFi, NFT and other functions; 2. Automatically execute contracts through code to reduce the risks of human intervention and fraud; 3. Build a DeFi ecosystem so that users can directly conduct financial operations such as lending and transactions; 4. Create and manage digital assets to ensure uniqueness and verifiability; 5. Improve the transparency and security of supply chain and identity verification; 6. Support DAO governance and realize decentralized decision-making.

Bitcoin, Chainlink, and RWA resonance rise: crypto market enters institutional logic? Bitcoin, Chainlink, and RWA resonance rise: crypto market enters institutional logic? Jul 16, 2025 am 10:03 AM

The coordinated rise of Bitcoin, Chainlink and RWA marks the shift toward institutional narrative dominance in the crypto market. Bitcoin, as a macro hedging asset allocated by institutions, provides a stable foundation for the market; Chainlink has become a key bridge connecting the reality and the digital world through oracle and cross-chain technology; RWA provides a compliance path for traditional capital entry. The three jointly built a complete logical closed loop of institutional entry: 1) allocate BTC to stabilize the balance sheet; 2) expand on-chain asset management through RWA; 3) rely on Chainlink to build underlying infrastructure, indicating that the market has entered a new stage driven by real demand.

python case-insensitive string compare if python case-insensitive string compare if Jul 14, 2025 am 02:53 AM

The most direct way to make case-insensitive string comparisons in Python is to use .lower() or .upper() to compare. For example: str1.lower()==str2.lower() can determine whether it is equal; secondly, for multilingual text, it is recommended to use a more thorough casefold() method, such as "stra?".casefold() will be converted to "strasse", while .lower() may retain specific characters; in addition, it should be avoided to use == comparison directly, unless the case is confirmed to be consistent, it is easy to cause logical errors; finally, when processing user input, database or matching

See all articles