I have a SDF which is a 2d numpy array and also an image feature array which is a 3d array, it has the various texture in the third dimension. So in my equation I have this:
ux = np.sum(cv2.blur(phi0*txtre, (3, 3)))/np.sum(cv2.blur(phi0, (3, 3)))
vx = np.sum(cv2.blur((1-phi0)*txtre, (3, 3)))/np.sum(cv2.blur((1-phi0), (3, 3)))
a = (txtre - ux)**2
b = (txtre - vx)**2
dphidt = dirac(phi) * (cv2.blur((a - b), (3, 3)))
phi += (dt * dphidt) #dt is just to maintain CFL condition
Here I have phi0 which is a heavside of SDF and is 2d array, and txtre which is a 3d array. however this line gives me broadcasting error.
Also later I need to take gradient and update the phi (SDF) with small change in phi called dphidt. So how to handle all the broadcasting?
Here dirac function is defined as follows
def dirac(p):
out = np.abs(p) <= 0.5