The line of code:

float b = blue(imq.pixels[loc];

should read:

float b = blue(img.pixels[loc]);

“img” instead of “imq” and note the missing close parentheses.