Optimization?
Let's recall the implementation of RasterUnionFind
was based on Quick-Union. However, we did not incorporate any improvements (union-by-size or path compression). That said, it seems our implementation is performing path compression! For example, consider the output of ImageRegions
for the color.png
file:
Number of regions: 7
Region labels:
0 1 1 3 3
1 1 1 3 3
1 1 12 13 13
15 15 13 13 13
15 15 13 13 24
Notice, for instance, all the pixels in regions labeled with $1$ are directly connected to the root (the parentID for every pixel in that region is $1$). So is the case for other regions. You will find a similar pattern if you run the ImageRegions
program for bw.png
file. In the README.md
file, elaborate if this is a lucky incidence or any aspect of our implementation increases the likelihood of this unplanned path compression. Keep the answer to a paragraph; be brief and to the point.