Connected components and noise reduction moved out in its own file.