# Import Image and apply pattern

**URL:** <https://discourse.processing.org/t/import-image-and-apply-pattern/12229>\
**Category:** Coding Questions\
**Created:** [June 21, 2019, 11:43am UTC](https://discourse.processing.org/t/import-image-and-apply-pattern/12229 "2019-06-21T11:43:57Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [July 14, 2019, 4:12pm UTC](https://discourse.processing.org/t/import-image-and-apply-pattern/12229/21 "2019-07-14T16:12:00Z")

</div>

It looks like you want your reaction diffusion to react stronger / faster / more often in different parts.

Here is a simple example without a mask. If the column is on the far left, it is almost never updated. If the column is on the far right, it is almost always updated. Columns in the middle have a 50% chance of updating.

```auto
void update() {
  for (int i = 1; i < width-1; i++) {
    if (random(width)<i) {
      for (int j = 1; j < height-1; j ++) {

```

Here is a simple diffusion of your base image (no mask) with variable updating of the columns in update(), as above:

 ![17%20AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/9139de2075a0c7bac758ceeff25273e662889968.jpeg)

You could do this per-pixel based on a mask, of course – given the brightness() of a mask pixel, have it more or less likely that the pixel will update – or have some pixels update 0, 1, 2, 3 times. Do it in update(), though – not in draw().

---

<div class="post-metadata">

**Author:** ![alice](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@alice](https://discourse.processing.org/u/alice)\
**Post date:** [July 14, 2019, 6:11pm UTC](https://discourse.processing.org/t/import-image-and-apply-pattern/12229/22 "2019-07-14T18:11:19Z")

</div>

> [@jeremydouglass](#):
>
> point-rect collis

HI Jeremy,

so this is the where I can control columns

```auto
void update() {
  for (int i = 1; i < width-1; i++) {
    if (random(100)<i) { //Column i
      
      for (int j = 1; j < height-1; j ++) { // column j

```

I’m trying to change a bit the value in order to control the rectangle : on the left I’m trying to don’t have the reaction diffusion at all but only to see the black original rectangles, the reaction diffusion it only starts from the middle to the right part, is it right how I’m changing the value here ?

```auto
if (random(100)<i) { //Column i

```

Thanks ! 🙂

---

<div class="post-metadata">

**Author:** ![alice](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@alice](https://discourse.processing.org/u/alice)\
**Post date:** [July 14, 2019, 6:28pm UTC](https://discourse.processing.org/t/import-image-and-apply-pattern/12229/23 "2019-07-14T18:28:07Z")

</div>

Do you think It works even If I have an oblique line instead of having columns? I’m studying the link that you sent me where It explains the rectangles, probably it works in the same way but at the moment I’m focusing in the columns,

Thanks!

[Previous page](https://discourse.processing.org/t/import-image-and-apply-pattern/12229.md?page=1)
