
312 19. Data VisualizationTechniques with WebGL
First we dene the histogram data structure: a long array that will represent the three-
dimensional matrix containing each RGB component in the graphic. We call this vari-
able ans. en we get the typed array containing pixels of the video frame. We call this
pixels. en we iterate through each RGBA component of the pixels array and convert
the [0-255] value of each RGB component in the pixels’ array to the [0-dim] domain
where dim is the dimension of our cube. Finally, we get the proper index of the histogram
array by generating it as one would do a lookup in a matrix. Once we get the index, ...