2013-03-11 48 views
1

我的問題是爲什麼以下代碼中的兩個直方圖是相同的。 由於圖片確實發生變化,首先顯示原始圖片,然後顯示全黑圖片。爲什麼直方圖是相同的[python + simplecv]

難道我錯過-使用simpleCV或者這也許是一個錯誤?

代碼:

from itertools import product 
from SimpleCV import Image 
from SimpleCV import Color 

if __name__ == '__main__': 
    pass 

def number_of_hues(picture): 
    image = Image(picture) 

    #convert the picture's space to HSV 
    image = image.toHSV() 
    image.show() 
    original_histogram = image.histogram() 


    (image_x_length, image_y_length) = image.size() 
    for i,j in product(range(image_x_length), range(image_y_length)): 
     image[i,j] = Color.BLACK 


    image.show() 

    new_histogram = image.histogram() 

    for o,n in zip(original_histogram, new_histogram): 
     if o != n: 
      print o,n 
+0

它工作正常。幾天前我已經更新了我的SimpleCV。 – Froyo 2013-03-17 23:22:26

回答

1

當最後一次你沒有從開發GitHub庫拉?設置項目調用中存在一個圖像類的bug,可以直接設置圖像。這是幾周前修復的。一般來說,您應該儘量避免直接循環圖像對象並直接設置像素,因爲它可能非常慢。如果您認爲您發現了錯誤,請將問題提交給我們的github回購,我們會盡快解決它。

+0

我已經在3周前安裝了simpleCV,所以我想這就是你所說的錯誤,但我會報告它以防萬一。 也謝謝你的回答。 – user1819238 2013-03-18 10:57:45

相關問題