Не так давно писал подобный helper:
var imageWidth = canvas.width,
imageHeight = canvas.height,
ctx = canvas.getContext('2d');
var getPixelDataByCoordinates = (function () {
var imageData = ctx.getImageData(0, 0, imageWidth, imageHeight).data;
return function (x, y) {
var pixelIndex = ((y * (imageWidth * 4)) + (x * 4));
if (!(pixelIndex in imageData)) {
return undefined;
}
var result = {
r: imageData[pixelIndex],
g: imageData[pixelIndex + 1],
b: imageData[pixelIndex + 2],
a: imageData[pixelIndex + 3]
};
result.weight = result.r + result.g + result.b + result.a;
return result.weight > 0 ? result : undefined;
};
})();
console.log(
getPixelDataByCoordinates(0, 0)
);