The program goes along each row looking for black pixels. When it finds one, the addq macro tests every coordinate to make sure that it falls within the image. If the program is rewritten so that it does a separate check for the edges of the image, testing of all the interior pixels can omit the test which ensures that the surrounding pixels are within the image.
To do this, the program could first use four loops, one to check the top row, one for each side and one for the bottom row, with each of these loops using the existing addq macro.
Then you can change the existing loop from:
Code: Select all
for(j=0;j<height;j++) {
for(i=0;i<width;i++,p++) {
Code: Select all
for(j=1;j<height-1;j++) {
for(i=1;i<width-1;i++,p++) {
I have no idea how much this would speed up the code, if at all, but it's worth a try.
Pete