How to read color average from camera-feed in square shaped chunks

edited May 2016 in Library Questions

I'm taking the example "TimeDisplacement" (examples > video > capture) and it reads the exact color information in rows of 4-pixels height. I need to make square shaped chunks (let's say 50x50px) and take the average color of them. So i can apply it to something similar as it's seen in the 'Mirror' example, the only difference is that I need the color information to be refreshed frame by frame, as in the "TimeDisplacement" example. any thoughts on how I could do this? Thank you!

Tagged:

Answers

  • Use the pixels[] array with three nested loops (one on the chunks, the two others on the pixels of the chunk).

  • @PhiLho I think that's exactly my problem, I don't know how to set the chunks in an array :/

  • "I don't know how to set the chunks in an array"
    Indeed, you are confused, because I don't understand your sentence, actually... :-D

    You don't have to "set the chunks in an array", you have to compute the average color of a chunk (an area of pixels), and set it in an array.

  • edited November 2014

    @PhiLho I mean, I don't know how to isolate a chunk using code... (i will explain further) the examples take an average of 4 lines, and it's easy because you take it from width4 pixels (4 rows of pixels). but how do i do it in a square area? let's say, 40rows 40columns? (being those 40 columns, lets say width/10, not the full lenght of the row) that's my question, how do i set that area in a for loop or whatever to be averaged. also I don't know how to make the average of the colors in some area.

  • Answer ✓

    "the examples take an average of 4 lines" "I don't know how to make the average of the colors in some area"
    That's the same idea, except you do it with more pixels.
    To cover an area, you have to do a nested loop, as said above: one for loop on the x coordinates, one on the y coordinates.

Sign In or Register to comment.