On many images there are random clusters of points that have been marked as road which are well above the road, in the grass, or on houses. They’re easily recognizable even without the original image because there’s a space between the large chunk of recognized road at the bottom and the incorrectly recognized road above it. I tried counting the number of pixels that were close to any given pixel to remove the chunks, but this didn’t work – the bad road pixels have a lot of other bad road pixels around them.
Next I tried “searching up” through the image and looking for any road that is floating above another section of road and getting rid of any “floating” road sections. This left thin vertical streaks of road in some places where some “floating” road squares were slightly touching lower road squares. So I then go back through the image horizontally and remove and sections of road that are not wide enough. The addition of this algorithm does give a slightly better result than without it and it doesn’t take much time, even on a 640×480 image.
I also sped up the various algorithms used by caching things that have to be computed often, such as an intensity-value-to-RGB-int cache and a red/green/blue to intensity value cache.
The quality of this is still mediocre though. There need to be either more or better heuristics involved.