# Help on video effect

**URL:** https://discourse.processing.org/t/help-on-video-effect/27942
**Category:** Libraries
**Created:** [February 19, 2021, 8:12pm UTC](https://discourse.processing.org/t/help-on-video-effect/27942 "2021-02-19T20:12:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Morais](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/morais/32/12152_2.png) [@Morais](https://discourse.processing.org/u/Morais)
#### Post date: [February 19, 2021, 8:12pm UTC](https://discourse.processing.org/t/help-on-video-effect/27942/1 "2021-02-19T20:12:25Z")

</div>

Hi everyone. I am new to coding.  
This “effect” is almost done in terms of the overall look, but I can’t understand how to smooth out the pixelated lines (examples below).  
There’s a difference between P2D/P3D, but it’s not enough. pixelDensity() got me to a better place, but the lines are still broken as you’ll see.

I am aware that this might not be the best way to produce this effect – I am open to learning other ways if necessary.

Here is the code:

//////////////////////////////////////////////////////////////////////////

```auto
import processing.video.*;
import processing.video.Movie;
Movie myMovie;

int cellSize = 1;
int cols, rows;

void setup() {
  size(1280, 720, P3D);
  cols = width / cellSize;
  rows = height / cellSize;
  colorMode(RGB, 255, 255, 255, 255);
  myMovie = new Movie(this, "movie.mp4");
  myMovie.loop();
  loadPixels();
  pixelDensity(2);
}

void draw() {
  background(0);

  if (myMovie.available()) {
    myMovie.read();
    myMovie.loadPixels();

    // Begin loop for columns
    for (int i = 0; i < cols; i++) {
      // Begin loop for rows
      for (int j = 0; j < rows; j++) {      
        // Where are we, pixel-wise?        
        int x = i*cellSize;
        int y = j*cellSize;
        int loc = (myMovie.width - x - 1) + y*myMovie.width; // Reversing x to mirror the image

        float r, g, b;

        r = red(myMovie.pixels[loc]);
        g = green(myMovie.pixels[loc]);
        b = blue(myMovie.pixels[loc]);
        // Make a new color with an alpha component

        float adjustBrightness = 1;
        r *= adjustBrightness;
        g *= adjustBrightness;
        b *= adjustBrightness;

        r = constrain(r, 0, 255);
        g = constrain(g, 0, 255);
        b = constrain(b, 0, 255);  

        color NewCol = color(r, g, b);
        pixels[loc] = NewCol;

        // Code for drawing a single rect
        // Using translate in order for rotation to work properly
        pushMatrix();
        translate(x+cellSize/2, y+cellSize/2);

        // Rotation formula based on brightness
        rotate((2 * PI * brightness(NewCol) / 255.0));
        rectMode(CENTER);       
        noFill();
        stroke(NewCol);
        strokeWeight(.1);     
        rect(0, 0, pmouseX, pmouseY);
        popMatrix();
      }
    }
  }
}

```

//////////////////////////////////////////////////////////////////////////

![P2D](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/ced6b3f128b3a9211385b300328dce8ed026d5ca.png) ![P3D](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7e90ef914f97746a045d0ef768fdd605b453b43c.png) ![with pixelDensity](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8e32d1230fcd1d760392ff2013e3c5e31c1bb374.png)

---

<div class="post-metadata">

### Author: ![Morais](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/morais/32/12152_2.png) [@Morais](https://discourse.processing.org/u/Morais)
#### Post date: [March 8, 2021, 5:48pm UTC](https://discourse.processing.org/t/help-on-video-effect/27942/2 "2021-03-08T17:48:09Z")

</div>

Just to share, helped me to get better results.  
I found this:

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/27972/clustering-pixels-in-an-image-by-colour-over-time)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

"Thing get a bit better if you add complications like:

1. randomly sample which pixels get to move each turn
2. let pixels swap at different distances depending on how far they are from their goal, with further pixels swapping farther
3. add random jitter to pixel swapping so that they don’t always head straight for the goal

Approaches like these can things can break up log-jams and create more fluid outcomes."

Basically, I just applied some randomness to the pixels and the artefacts went away.  
Maybe it is not a solution on its own but it did the trick.

Thank you.
