edge detection slice and merge (optimization needed)