Tests
You can test your implementation by running the ImageRegions.main
method with other sample images in the resources/tiny
folder. For example, running it for the bw.png
image file should produce the following output:
Number of regions: 2
Region labels:
0 0 0 0 0
0 0 0 0 0
0 0 12 12 12
0 0 12 12 12
0 0 12 12 12
You can also add unit tests in UnionFindTest.java
file. Notice there is already a sample to recreate a scenario similar to the case above where there are two regions in the image.
You must add (at least) two more unit tests to this file to consider other (sufficiently different) scenarios.
Through unit testing and by running the ImageRegions
program for various sample images, you will gain confidence in the correctness of your implementation of RasterUnionFind
data structure.