You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Great work! I work with it a bit and found that you are not supporting NxM images.
I think that you have a small logic error in the intensities function (pricessing.js file). The inner loop working on the "imagedata.height", as well the outer loop. Moreover the calculation of "i" seems to be different from the other functions.
I suggest this fix, it worked well on NxM images.
intensities: function(imagedata) {
if (!imagedata.data) {
// it's a canvas, extract the imagedata
var canvas = imagedata;
var context = canvas.getContext("2d");
imagedata = context.getImageData(0, 0, canvas.width, canvas.height);
}
var lumas = new Array(imagedata.height);
for (var y = 0; y < imagedata.height; y++) {
lumas[y] = new Array(imagedata.width);
for (var x = 0; x < imagedata.width; x++) {
//var i = x * 4 + y * 4 * imagedata.width;
var i = (y * 4) * imagedata.width + x * 4;
var r = imagedata.data[i],
g = imagedata.data[i + 1],
b = imagedata.data[i + 2],
a = imagedata.data[i + 3];
var luma = a == 0 ? 1 : (r * 299/1000 + g * 587/1000
+ b * 114/1000) / 255;
lumas[y][x] = luma;
}
}
return lumas;
}
The text was updated successfully, but these errors were encountered:
pnidl
pushed a commit
to pnidl/hog-descriptor
that referenced
this issue
Mar 10, 2017
Hi,
Great work! I work with it a bit and found that you are not supporting NxM images.
I think that you have a small logic error in the intensities function (pricessing.js file). The inner loop working on the "imagedata.height", as well the outer loop. Moreover the calculation of "i" seems to be different from the other functions.
I suggest this fix, it worked well on NxM images.
intensities: function(imagedata) {
if (!imagedata.data) {
// it's a canvas, extract the imagedata
var canvas = imagedata;
var context = canvas.getContext("2d");
imagedata = context.getImageData(0, 0, canvas.width, canvas.height);
}
}
The text was updated successfully, but these errors were encountered: