Question: 10. (programming question) Finding connected components in a binary image. a) An Union-Find data structure should be implemented, with the most efficient algorithm, as an




10. (programming question) Finding connected components in a binary image. a) An Union-Find data structure should be implemented, with the most efficient algorithm, as an abstract data type a class in C++ or java) with the following operations. uandf(n): constructs an union-find data type with n elements, 1, 2, ...,n. make_set(i): creates a new set whose only member and thus representative) is i. union sets(i, j): unites the dynamic sets that contains i and j, respectively, into a new set that is the union of these two sets. find_set(i): returns the representative of the set containing i final sets(): returns the total number of current sets and finalizes the current sets: (i) make_set() and union_sets) will have no effect after this operation and (i) resets the representatives of the sets so that integers from 1 to final sets will be used as representatives. b) Design and implement (write a program, an algorithm to find the connected components in a binary image using Union-Find data structure in a). An ASCII file containing a binary image is available (see girl.img and img_readme) as the input of your program. The output of the program should be the following in this specified order: 1. the input binary image, 2. the connected component image where each component is labelled with a unique char- acter, 3. a list sorted by component size, where each line of the list contains the size and the label of a component, 4. same as 2 with the connected components whose sizes are less than four removed. In your gaul account, you should create a directory called "asn2" which contains your asn2 solution.pdf for question 1 to question 9 and the description of algorithm and the explanation of correctness and complexity of final_set() in 10 a) and your algorithm in 10 b); your program for question 10; the input file with name infile; and the makefile. The makefile should be written such that the command "make clean will remove all the "*.0" files and the command "make" will generate an executable file asn2 that can be run by typing "asn2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
