You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:计算图像中不规则灰色区域的像素平均强度

计算图像灰色区域的像素平均强度

我需要获取图像中灰色区域的像素平均强度,相关图像如下:
待分析图像

我尝试通过以下代码片段获取像素坐标与强度并进行计算(仅展示计算部分):

xp = x_centre - R2cos40
yp = y_centre - rayon2
angle = math.atan((x_centre - xp)/(y_centre - yp))
somme_intensite = 0
compteur_pixels = 0

for x in range(x_centre - R2sin40, x_centre + R2cos40):
    for y in range(y_centre - rayon2, y_centre - R1sin40):
        if (x <= rayon2 * math.sin(angle) and \
            y < rayon1 and\
                y > R1sin40 and\
                    angle < 315 and \
                        angle >= 255):
            somme_intensite += image.getpixel((x, y))
            compteur_pixels += 1
            xp += 1
            yp += 1
        else:
            xp += 1
            yp += 1
            
intensite_moyenne = somme_intensite / compteur_pixels
intensite_pourcentage = (intensite_moyenne / 255) * 100

希望能得到帮助,不胜感激。

内容的提问来源于stack exchange,提问作者younesslamine

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 19:55:07