我写了一个方法,使图像的某些像素值变白。 在那个方法中,我调用了一个名为“meanfilter”的方法。 当我调用该方法时,像素值不会分配给该图像。但是,当我删除该调用时,代码工作得很好。我不知道为什么会这样。 这是我的代码:
0,1,2,3
Smad3_pS423/425_customer,0,1,0.664263
Smad3_pS423/425_customer,0,2,0.20991100000000001
Smad3_pS423/425_customer,0,3,0.09980900000000001
Smad3_pS423/425_customer,5,1,0.059652
Smad3_pS423/425_customer,5,2,0.190174
Smad3_pS423/425_customer,5,3,0.13885
a-Tubulin,0,1,0.072436
a-Tubulin,0,2,0.06828200000000001
a-Tubulin,0,3,0.087989
a-Tubulin,5,1,0.08396
a-Tubulin,5,2,0.076102
a-Tubulin,5,3,0.068119
在上面的代码中,计数大约是5000,所以我预计至少有一半的图像是白色的,但事实并非如此。
这是我的平均过滤方法:
def getColorArrayFromFiltered(self,image):
image=Image.open(image).convert("RGBA")
image=image.resize((100,100))
#tempImage is another image from somewhere else
imagepix1 = self.tempImage.load()
imagepix2 = image.load()
count = 0
image= self.meanFilter(image,3)
for x in range(100):
for y in range(100):
if self.isWhite(imagepix1[x,y]):
count+=1
imagepix2[x,y]=(255,255,255)
print count
image.save("dddd.png")