Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. Consider an image I where you access the intensity value of each pixel of the image with Ily. Suppose the image is grayscale, so
3. Consider an image I where you access the intensity value of each pixel of the image with Ily. Suppose the image is grayscale, so I y returns an integer. Given a pixel p, you can use I[p] as a shortcut. We wish to find all connected components where a connected component is a grouping of pixels that are connected and have identical intensity values. Two pixels are connected if they share an edge. They are not connected if they share only a corner. (a) Assume that you know nothing about disjoint sets. Give an algorithm in pseudocode for finding the connected components. Think carefully about what data structure you will use. Your algo- rithm doesn't necessarily need to be efficient. And the end of the algorithm you should have one instance of the data structure per connected component. You do not need to be super precise in your description - just give the general idea. (b) Now give an algorithm for finding the connected components using disjoint sets. You'll want to start by creating and initializing a 2-dimensional array of representative nodes - one node for each pixel. You can assume you have makeSet() (which returns a representative node), union() and find(). You may not necessarily use all three. Describe your algorithm in pseudocode. 3. Consider an image I where you access the intensity value of each pixel of the image with Ily. Suppose the image is grayscale, so I y returns an integer. Given a pixel p, you can use I[p] as a shortcut. We wish to find all connected components where a connected component is a grouping of pixels that are connected and have identical intensity values. Two pixels are connected if they share an edge. They are not connected if they share only a corner. (a) Assume that you know nothing about disjoint sets. Give an algorithm in pseudocode for finding the connected components. Think carefully about what data structure you will use. Your algo- rithm doesn't necessarily need to be efficient. And the end of the algorithm you should have one instance of the data structure per connected component. You do not need to be super precise in your description - just give the general idea. (b) Now give an algorithm for finding the connected components using disjoint sets. You'll want to start by creating and initializing a 2-dimensional array of representative nodes - one node for each pixel. You can assume you have makeSet() (which returns a representative node), union() and find(). You may not necessarily use all three. Describe your algorithm in pseudocode
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