Friday, July 22, 2005

There was a problem with the cross stitch chart generator that I just uploaded a fix for. The code that reduces the number of isolated pixels is very cpu intensive because it needs to sort the regions according to the number of pixels in them. Then the regions with a number of pixels below the threshold are merged into the closest neighbor. The sorting after a merge was too slow, so I added code to only resort the list of regions when the next candidate for removal has also been a closest neighbor. I just uploaded "Ducks" as a test and the performance was tolerable. For images with too many regions, sorting after every merge is just too slow.
I also added code to make the removal of isolated pixel regions more robust. I added a check to do one last resort before bailing out of the loop. I couldn't prove that it was a problem, but just in case there is something else going on, I thought it best to be safe. I also added a call to reduce the number of isolated pixels after the mapping to DMC floss happens. So now the pixel regions are merged before and after the mapping method call. I may change this code again later if I can prove that the mapping to DMC floss won't ever create an extra isolated pixel.

0 Comments:

Post a Comment

<< Home