Issue with Pixel in Canvas
micah-williamson opened this issue · comments
Offending lines-
Canny calls _traverseEdge.
Canny.prototype._traverseEdge = function(current, imgData, threshold, traversed) {
...
var neighbors = getEdgeNeighbors(current, imgData, threshold, traversed);
...
};
Which called getEdgeNeighbors in the helpers.
exports.getEdgeNeighbors = function(i, imgData, threshold, includedEdges) {
var neighbors = [],
pixel = new Pixel(i, imgData.width, imgData.height);
for(var j = 0; j < pixel.neighbors.length; j++)
if(imgData.data[pixel.neighbors[j]] >= threshold && (includedEdges === undefined || includedEdges.indexOf(pixel.neighbors[j]) === -1))
neighbors.push(pixel.neighbors[j]);
return neighbors;
};
Which constructs a new pixel with the pixel index, and the x/y coords. This is defined in cabbage.min.js (which is minified! why??)
And blows up on e.shift
function b(a,b,e){var f=this;this.x=a,this.y=b,this.neighbors={},e&&d.forEach(function(a){f[a]=e.shift()}),
b
is the Pixel constructor. a
is the pixel index, b
is the x coord, and e
is the y coord.
Foreach item in d
('r', 'g', 'b', 'a') it calls e.shift- which is a number and does not have a shift method.
Could you tell me where the source to this stuff is? Minified code makes it difficult to debug :)
(e instanceof Array) && d.forEach(function(a) {
f[a] = e.shift()
});