Question
You are given an image, as a list of pixels it contains. Each pixel has a given color coded in some format. Two colors are
You are given an image, as a list of pixels it contains. Each pixel has a given color coded in some format. Two colors are said to be of the same family if they are just a different hue of the same color. Since this is hard to determine, you do have a function you can call, where you provide 2 pixels, and it returns whether the 2 are from the same color family or not (it cannot tell you what the color family is though). Note that those families are closed sets: if A is of the same family as B, and B of the same family as C, then A is of the same family as C. Your problem now is that you would like to know if the image you received has one color that dominates all others. In other words, is there a family of colors so that the count of pixels in that family exceeds the count of pixels that are not in that family? Give a Divide-and-Conquer algorithm that can detect this (returning only yes or no, and perhaps one pixel from that color family). Your algorithm should use the function for comparing pixels only O(n log n) times, where n is the number of pixels in the image.
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