第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

程序不打印結(jié)果

程序不打印結(jié)果

翻閱古今 2022-06-22 19:48:49
現(xiàn)在,我正在使用以下程序,但我無法獲得所需的圖像時刻、質(zhì)心等。代碼:import cv2import numpyfrom matplotlib.pyplot import imreadfrom numpy import mgrid, sumimage = imread('imagemoment.png')def moments2e(image):    assert len(image.shape) == 2  # only for grayscale images    x, y = mgrid[:image.shape[0], :image.shape[1]]    moments = {}    moments['mean_x'] = sum(x * image) / sum(image)    moments['mean_y'] = sum(y * image) / sum(image)    # raw or spatial moments    moments['m00'] = sum(image)    moments['m01'] = sum(x * image)    moments['m10'] = sum(y * image)    moments['m11'] = sum(y * x * image)    moments['m02'] = sum(x ** 2 * image)    moments['m20'] = sum(y ** 2 * image)    moments['m12'] = sum(x * y ** 2 * image)    moments['m21'] = sum(x ** 2 * y * image)    moments['m03'] = sum(x ** 3 * image)    moments['m30'] = sum(y ** 3 * image)    # central moments    moments['mu01']= sum((y-moments['mean_y'])*image) # should be 0    moments['mu10']= sum((x-moments['mean_x'])*image) # should be 0    moments['mu11'] = sum((x - moments['mean_x']) * (y - moments['mean_y']) * image)    moments['mu02'] = sum((y - moments['mean_y']) ** 2 * image)  # variance    moments['mu20'] = sum((x - moments['mean_x']) ** 2 * image)  # variance    moments['mu12'] = sum((x - moments['mean_x']) * (y - moments['mean_y']) ** 2 * image)    moments['mu21'] = sum((x - moments['mean_x']) ** 2 * (y - moments['mean_y']) * image)    moments['mu03'] = sum((y - moments['mean_y']) ** 3 * image)    moments['mu30'] = sum((x - moments['mean_x']) ** 3 * image)    # opencv versions    # moments['mu02'] = sum(image*(x-m01/m00)**2)    # moments['mu02'] = sum(image*(x-y)**2)    # wiki variations    # moments['mu02'] = m20 - mean_y*m10    # moments['mu20'] = m02 - mean_x*m01你能幫我解決這個問題嗎?非常感謝。
查看完整描述

1 回答

?
紫衣仙女

TA貢獻1839條經(jīng)驗 獲得超15個贊

乍一看,我看到的一個問題是,您已經(jīng)定義了函數(shù)moments2e(image)但沒有調(diào)用它。您需要moments2e(image)在函數(shù)定義之外調(diào)用該函數(shù)。


import cv2

import numpy

from matplotlib.pyplot import imread

from numpy import mgrid, sum


image = imread('imagemoment.png')


def moments2e(image):

    assert len(image.shape) == 2  # only for grayscale images

    x, y = mgrid[:image.shape[0], :image.shape[1]]

    .

    .

    .

    return moments

moments = moments2e(image)

print(moments)


查看完整回答
反對 回復 2022-06-22
  • 1 回答
  • 0 關注
  • 115 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號