Code can now work with distance transform as I changed !=0 to ==255