Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Pixel in Canvas #6

Open
micah-williamson opened this issue Dec 30, 2016 · 2 comments
Open

Issue with Pixel in Canvas #6

micah-williamson opened this issue Dec 30, 2016 · 2 comments

Comments

@micah-williamson
Copy link

micah-williamson commented Dec 30, 2016

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 :)

@Tiantian-kaixin
Copy link

(e instanceof Array) && d.forEach(function(a) {
f[a] = e.shift()
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@micah-williamson @Tiantian-kaixin and others