Question
Design and implement (write a program) an algorithm to find the connected components in a binary image using Disjoint-Set data structure in a). An ASCII
Design and implement (write a program) an algorithm to find the connected components in a binary image using Disjoint-Set 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 character, 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 three deleted.
girl.img
+++++++++ +++ +++++++++ +++ ++++++++ +++ +++++++ ++++ ++++++ ++ ++++ +++++ ++ ++++ +++ ++ +++++ ++ ++ + + +++++ ++ ++ + ++++ ++ ++++++ +++++ + ++++ ++++++++ +++ ++++++ +++++ + ++++++ ++++++++++ +++++ +++++++ +++ + +++++++++++++++ +++++ ++++++++ ++ + + +++++++++++++++++ +++ +++++++++ +++ ++ ++++++++++++++++++ ++ ++++++++++ + +++ + +++++++++++++++++++ +++ +++++++++++ + ++ +++ ++++++++++++++++++ + +++ ++++++++++++ + + ++ ++++++++++++++++++ + ++++ +++++++++++++ ++++ ++ +++++++++++++++++++++ ++++ ++++++++++++++ +++++ ++++++++++++++++++++++ ++++ ++++++++++++++ ++++++ +++++++++++++++++++++ ++++ +++++++++++++ ++++++++++++++++++++++++++ ++++ +++++++++++++ +++ ++++++++++++++++++++ ++++ ++++++++++++ +++ ++++++++++++++++ ++ ++++ ++++++++++++ + +++++++++++++++++++ +++++ ++++++++++++ + +++++++++++++++++++ +++++ +++++++++++ +++++++++++++++++++ + + +++++ +++++++++++ ++++++++++++++++++++ +++++ +++++ +++++++++++ +++++++++++++++++++ ++++ +++++++ +++++++++ ++++++++++++++++++++ +++++++++++ +++++++++ +++++++++ +++++++++++++++++++ ++++++++++ + +++++++++++ +++++++++ ++++++++++++++++++ +++++++ +++++ ++++++++++++ ++++++++ ++++++++++++++++++ +++++++ +++++ +++++ +++++++ ++++++++ +++++++++++++++++ +++++++ ++++ + ++ +++++++ ++++++++ ++++++++++++++++ + +++ +++ ++++++++ +++++++ +++++ ++++++++++ + ++ +++ ++++++++++ +++++++ ++++++ +++++++++ +++ ++ +++++++++ +++++++ ++++++ ++++++++ ++++ ++ ++++++++ +++++++ +++++ ++++++++ ++++ ++ ++++++++ +++++ +++++++ +++++++ +++++ + ++++++++ +++++ +++++++ ++++ ++++++ + ++++++++ +++++ ++++++++++++++ ++++++ ++ +++++++ ++++ +++++++ + ++ +++++++ ++ ++++++++ ++++ +++++++ +++++ ++++++++ ++ +++++++ ++++ +++++ +++++ +++++++++ ++ + ++++++++ +++ ++++++++++ ++++++++++ ++ ++ +++++++++ ++ +++++ ++++ +++++++++++ +++++++ +++++++++ ++ ++++++++++ +++++++++++ ++++ ++++++++++ ++ + +++++ + +++++++++++++ ++++++++++ + +++++ + +++++++++++++ ++++++++++ + +++++ + ++++++++++++++ +++++++++++ + ++ ++ +++++++++++++++ +++++++++++ ++ + +++++++++++++++++ +++ +++++ +++ +++++++++++++ ++ + +++++++++++++++++ ++++++++++ ++ +++++++++++++ + + +++++++++++++++++++ +++++ ++++++++++++++ + ++++++++++++++++++++ ++++ ++++++++++++++ +++++++++++++++++++++ ++++++ +++++++++++++++ ++ +++++++++++++++++++++++ +++++++++++++++ ++ +++++++++++++++++++++++ ++++++++++++++++ +++ +++++++++++++++++++++++++ ++++++++++++++++ +++++++++++++++++++++++++++++ ++++++++++++++++ +++++++++++++++++++++++++++ +++++++++++++++++ + ++++++++++++++++++++++++ ++++++++++++++++ ++ + ++ ++++++++++++++++++++++ +++++++++++++ +++++ ++++ +++++++++++++++++++++++ ++++++++++++ +++++++ ++ + ++++++++++++++++++++++ ++++++++++ +++++ ++ ++ +++++++++++++++++++++ +++++++++ +++ + + + ++++++++++++++++++++ ++++++ ++ + +++++++++++++++++++++ ++++++ ++ ++ +++++++++++++++++++ +++++ +++ ++ ++++++++++++++++++ ++++ +++ ++ +++++++++++++++++++ ++++
and img -readme
File girl.img contains a 71 by 71 binary image in plain text. In this file, a + means 1 and a space means 0. We only consider the connected components of 1. The total number of components is less than 26. Therefore you can use letters from 'a' to 'z' to identify all the components. We use 4 connectivity for +. Therefore ++ and + are considered connected. + However + and + are not considered connected. + +
in java please
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started