Why is skimage.euler_number gives me euler number of 1, but according to the formula it should give me 2

Viewed 198
import numpy as np
from skimage.measure import euler_number
n = 7
cube = np.zeros((n, n, n), dtype=int)
cube[1:6,1:6,1:6] = 1 #creates a cube of 5x5
euler_no = euler_number(cube)

'This is giving me o/p as 1 but according to the formula euler_number = F + V − E it should give me 2 as number of faces = 6, number of vertices = 8 and number of edges = 12 but using this method I am getting Euler number as 1. Am I doing anything wrong?

1 Answers

It looks like skimage does this wrong. The documentation states:

For 3D objects, the Euler number is obtained as the number of objects plus the number of holes, minus the number of tunnels, or loops.

According to their definition, a cube (or any solid object) has an Euler number of 1. Unfortunately their definition is wrong. In particular, I believe it always returns half the Euler number in 3D. If I’m right, to get the actual 3D Euler number,

euler_no = 2 * euler_number(cube)
Related