Am having am image, i have to read all the pixel values of that image. And i have to do it in webOS. What are the ways to do that?
Asked
Active
Viewed 160 times
1
-
1I am just guessing but maybe for that we have the PDK(?) It will allow you to use native C, C++ which are more widely used for image processing than javascript. However if there is a way we can do with Mojo I am interested in knowing the answer too :) – nacho4d Jun 03 '11 at 05:55
-
Thanks @nacho4d, i didn't think of pdk, the native way of development. i ll try using that. And i have got some script to get pixel and manipulating it. once i got solution, sure i ll post it. – Androider Jun 03 '11 at 09:52
1 Answers
1
This question is somewhat similar to another one, which I answered here. Basically, you'll want to draw that image to a canvas, use getImageData
to get the pixel array, and then just access the pixel within the array.
In summary, this example finds the green component of the pixel at (5,2):
var canvas = document.getElementById(canvasID);
var context = canvas.getContext('2d');
var image = context.getImageData(0,0,canvas.width,canvas.height);
var index =(5*image.width+2)*4;
//six columns of pixels, plus two for the third row.
//Multiply by four, because there are four channels.
image.data[index+1] = 0; //Plus one, because we want the second component (R,G,B,A).