testing.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:retinal-exudates-detection 作者: getsanjeev 项目源码 文件源码
def calculate_entropy(image):
    entropy = image.copy()
    sum = 0
    i = 0
    j = 0
    while i < entropy.shape[0]:
        j = 0
        while j < entropy.shape[1]:
            sub_image = entropy[i:i+10,j:j+10]
            histogram = cv2.calcHist([sub_image],[0],None,[256],[0,256])
            sum = 0
            for k in range(256):
                if histogram[k] != 0:                   
                    sum = sum + (histogram[k] * math.log(histogram[k]))
                k = k + 1
            entropy[i:i+10,j:j+10] = sum
            j = j+10
        i = i+10
    ret2,th2 = cv2.threshold(entropy,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
    newfin = cv2.erode(th2, cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(3,3)), iterations=1)
    return newfin
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号