This content originally appeared on DEV Community and was authored by Daniel Dominguez
The greedy randomized adaptive search procedure (also known as GRASP) is a metaheuristic algorithm commonly applied to combinatorial optimization problems in which each iteration consists basically of two phases: construction and local search. The construction phase builds a feasible solution, whose neighborhood is investigated until a local minimum is found during the local search phase.
First, the darkest pixel is found. Then a number of random lines are drawn through that point, and the pixel values along each line are added together. The line with the darkest average is chosen, and the value of that line is subtracted from the image. Then the whole process is started over again for however many lines we are drawing.
By the nature of the algorithm, the optimal line drawing configuration is probably not achieved, but performance is far superior to the naive method of checking every line.
This content originally appeared on DEV Community and was authored by Daniel Dominguez

Daniel Dominguez | Sciencx (2021-09-16T00:27:34+00:00) Using a greedy randomized algorithm to create art. Retrieved from https://www.scien.cx/2021/09/16/using-a-greedy-randomized-algorithm-to-create-art/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.