# How to iterate video.pixels.length for random area of image

**URL:** <https://discourse.processing.org/t/how-to-iterate-video-pixels-length-for-random-area-of-image/39367>\
**Category:** Libraries\
**Created:** [October 20, 2022, 4:41am UTC](https://discourse.processing.org/t/how-to-iterate-video-pixels-length-for-random-area-of-image/39367 "2022-10-20T04:41:45Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 20, 2022, 2:11pm UTC](https://discourse.processing.org/t/how-to-iterate-video-pixels-length-for-random-area-of-image/39367/19 "2022-10-20T14:11:36Z")

</div>

> the sampled color still drawn beyond that x and y value

If you don’t want to sample beyond x \< 100 and y \> 240 then you’ve got to limit where the mouse traps clicks. I’ve shown you this code previously. The last post of this thread:[https://discourse.processing.org/t/how-to-iterate-over-2d-region-with-1d-pixels-array/39336/23](https://discourse.processing.org/t/how-to-iterate-over-2d-region-with-1d-pixels-array/39336/23)

One change would be to not use the counter but use the most recent code that was posted above; ie, use id = x + y\*width.

---

_[View the full topic](https://discourse.processing.org/t/how-to-iterate-video-pixels-length-for-random-area-of-image/39367)._
