Skip to content

alexchatwin/floodFill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

floodFill

A basic floodfill algorithm in python. Takes an array of numbers, and will return an array of the different regions present, expessed as numbers A region is defined as all cells of the same value, with a direct N/E/W/S connection between

e.g

[[2 2 2 2 1 1 0 2 0 2 0 2 2 2 1] [0 0 1 2 0 2 2 1 0 2 0 0 2 0 2] [1 1 1 0 2 0 2 0 2 2 1 2 0 2 0] [1 2 2 2 0 0 1 1 1 1 2 1 2 1 0] [1 1 1 0 1 0 2 0 2 0 1 2 2 1 1] [2 1 0 2 0 1 1 1 0 2 2 0 0 1 1] [0 0 2 1 1 2 2 2 0 1 2 0 2 0 2] [0 1 1 0 2 2 2 1 1 2 0 2 2 0 2] [0 0 2 2 2 0 1 1 2 2 0 2 1 1 0] [2 2 2 2 1 2 1 2 2 1 1 2 2 1 0] [2 2 0 2 0 2 0 1 1 1 1 1 1 0 2] [1 1 1 1 2 2 2 2 1 2 0 1 1 2 0] [2 1 1 0 2 0 2 0 0 1 0 2 0 2 2] [2 2 0 0 0 1 0 0 1 0 2 1 1 0 1] [1 0 2 0 2 0 1 1 1 2 2 0 1 1 0]]

becomes

[[ 1. 1. 1. 1. 2. 2. 0. 3. 0. 4. 0. 5. 5. 5. 6.] [ 0. 0. 7. 1. 0. 8. 8. 9. 0. 4. 0. 0. 5. 0. 10.] [ 7. 7. 7. 0. 11. 0. 8. 0. 4. 4. 12. 13. 0. 14. 0.] [ 7. 15. 15. 15. 0. 0. 16. 16. 16. 16. 17. 18. 19. 20. 0.] [ 7. 7. 7. 0. 21. 0. 22. 0. 23. 0. 24. 19. 19. 20. 20.] [25. 7. 0. 26. 0. 27. 27. 27. 0. 28. 28. 0. 0. 20. 20.] [ 0. 0. 29. 30. 30. 31. 31. 31. 0. 32. 28. 0. 33. 0. 34.] [ 0. 35. 35. 0. 31. 31. 31. 36. 36. 37. 0. 33. 33. 0. 34.] [ 0. 0. 31. 31. 31. 0. 36. 36. 37. 37. 0. 33. 38. 38. 0.] [31. 31. 31. 31. 39. 40. 36. 37. 37. 41. 41. 33. 33. 38. 0.] [31. 31. 0. 31. 0. 40. 0. 41. 41. 41. 41. 41. 41. 0. 42.] [43. 43. 43. 43. 40. 40. 40. 40. 41. 44. 0. 41. 41. 45. 0.] [46. 43. 43. 0. 40. 0. 40. 0. 0. 47. 0. 48. 0. 45. 45.] [46. 46. 0. 0. 0. 49. 0. 0. 50. 0. 51. 52. 52. 0. 53.] [54. 0. 55. 0. 56. 0. 50. 50. 50. 51. 51. 0. 52. 52. 0.]]

About

A basic flood fill algorithm in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages