olivierlando / path-from-image

Try to find the shortest path between two points of an image, following pixels matching a given colors pattern.
MIT License
7 stars 0 forks source link

Different path co-ordinates #2

Open MRK196 opened 6 years ago

MRK196 commented 6 years ago

Hi @olivierlando, I have installed this excellent package for my test application, however when I am testing the code functionality with the example you proved (and with the same image) I am getting different co-ordinates from the ones you are expecting to get.

Instead of these co-ordinates [62, 413], [63, 406], [69, 390], I am getting:

[63, 294], [69, 288], [95, 292], [121, 304]...

I am using the exact same test code you provided:

 `const fs = require('fs');
 const jpeg = require('jpeg-js');
 const PathFromImage = require('path-from-image');

  const bluePointCoords = [62, 413];
 const redPointCoords = [514, 39];

 const image = jpeg.decode(fs.readFileSync('road.jpg'), true);
 const pathFromImage = new PathFromImage({
   width: image.width,
   height: image.height,
   imageData: image.data,
   colorPatterns: [{ r: [60, 255], g: [0, 70], b: [60, 255] }], // description of the mauve / ping color
 });
 const path = pathFromImage.path(bluePointCoords, redPointCoords); 

Any reason for such a discrepancy? Thanks

RyanRizzo96 commented 6 years ago

Hi, I believe it has something to do with this line: colorPatterns: [{ r: [60, 255], g: [0, 70], b: [60, 255] }],.

I am struggling to understand how this works exactly.