Pixel search algorithm

Continuing to exploit my recently found spare time, I thought it would be fun to see what happens if you scan a bitmap in search for the greatest color pixels. Turned out to be pretty cool! Even though you can probably do this a million times faster in Photoshop, I’m still pretty happy with the result. Check the images below. Check my flickr site for more details.

paint taxi

paint traffic

paint market

So, how does it work:

  • Sort all the pixels by color. 0xFFFFFF first, 0×000000 last, this means that yellowish pixels will be searched first.
  • Remove the first pixel from the sorted pixels, and find the neighboring pixel with the greatest value. Remove this pixel from the list.
  • Continue until no neighbors are found.
  • Repeat step one until no pixels are left.

It is a very slow algorithm, so I made this video of the process and increased the speed.

UPDATE: made it faster, sorting the pixels had a slow element to it. Now the algorithm is finished within several seconds.