I am trying to convert:
var ic = [[[123,231,12],[56,43,124]],[[78,152,76],[64,132,200]]]
to (each element of the sub array has the average value of the sub array)
var ig = [[[122,122,122],[74,74,74]],[[102,102,102],[132,132,132]]]
Here is my code, the average function works, but it is not returning the correct new array:
var color2grey = function (image /* this is the image in color*/) {
const average = function([a,b,c]) {
return [((a+b+c)/3), ((a+b+c)/3), ((a+b+c)/3)]
};
return image.map(function(subArray) {
average(subArray);
});
}
This is what I am getting:
returns- (2) [undefined, undefined] 0 : undefined 1 : undefined length : 2 proto : Array(0)