I am creating a drawing app. I have succeeded to do everything. When I paint the image with a dark color, some white pixels appear at the edges. I tried to change the value
Your check for the outline is simply too strict, marking light gray pixels as ones you cannot color in. I simply tweaked your threshholds:
function matchOutlineColor (r,g,b,a,e) {
return a >= 150;
}
Notice my much higher numbers for the white value and alpha. You could maybe tweak this further but this looks good to me. Here are some before and after photos:
Before (zoomed in 200%)
After (zoomed in 200%)