Python图片数据处理怎么样图找白色区域?

这样一张9000*7000像素的图片该怎么样实现找出两个圆的区域。求大佬Python图片数据处理怎么样图找白色区域?

# -*- coding: gbk -*-

import cv2

import numpy as np

image_path = r"C:\Users\17607\Desktop\smls pictures\Pic_20231122151507973.bmp"

def row_method(src):

image_width = src.shape[1]

image_height = src.shape[0]

image = np.array(src)

cimage = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # 灰度图

circles = cv2.HoughCircles(cimage, cv2.HOUGH_GRADIENT, 1, 40, param1=50, param2=30, minRadius=0, maxRadius=0)

circles = np.uint16(np.around(circles)) # 取整

for i in circles[0, :]:

center_x, center_y, radius = i[0], i[1], i[2]

if 0 <= center_x - radius < image_width and 0 <= center_x + radius < image_width and \

0 <= center_y - radius < image_height and 0 <= center_y + radius < image_height:

cv2.circle(image, (i[0], i[1]), i[2], (0, 0, 255), 2) # 在原图上画圆,圆心,半径,颜色,线框

cv2.circle(image, (i[0], i[1]), 2, (255, 0, 0), 2) # 画圆心

cv2.putText(image, "param1=250, param2=58", (20, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (0, 0, 255), 2)

cv2.imshow("row_circles", image)

src = cv2.imread(image_path) # 读取图片位置

resized_image = cv2.resize(src, (src.shape[1] // 10, src.shape[0] // 10))

cv2.namedWindow("input image", cv2.WINDOW_AUTOSIZE)

cv2.imshow("input image", resized_image)

threshold_OTSU_method(resized_image)

row_method(resized_image)

cv2.waitKey(0)

cv2.destroyAllWindows()

这个只能得到Python图片数据处理怎么样图找白色区域?有很多没用信息Python图片数据处理怎么样图找白色区域?希望能得到这两个区域。。求大佬

以上是 Python图片数据处理怎么样图找白色区域? 的全部内容, 来源链接: utcz.com/p/939105.html

回到顶部