python如何去除非常扁的图像,采用离心率计算

labels = [2,3,7] 

# or whatever you have 

good_labels = []

for label in labels: m = matrix == label

non_empty_columns = sum(sum(m)>0)    

non_empty_rows = sum(sum(m.transpose())>0)   

 if 1.0 * non_empty_rows / (non_empty_columns+0.001) > threshold:       

    good_labels.append(label)

That will remove very long (vertically) blobs, turn rows and columns around to remove horizontally stretched blobs.

参考的连接

https://stackoverflow.com/questions/8158647/eccentricity-estimation-in-python

你可能感兴趣的:(python如何去除非常扁的图像,采用离心率计算)