# Blur / Filter only part of the image / canvas? (Masking?)

**URL:** <https://discourse.processing.org/t/blur-filter-only-part-of-the-image-canvas-masking/4760>\
**Category:** Coding Questions\
**Created:** [October 22, 2018, 7:23pm UTC](https://discourse.processing.org/t/blur-filter-only-part-of-the-image-canvas-masking/4760 "2018-10-22T19:23:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![evn](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@evn](https://discourse.processing.org/u/evn)\
**Post date:** [October 22, 2018, 7:23pm UTC](https://discourse.processing.org/t/blur-filter-only-part-of-the-image-canvas-masking/4760/1 "2018-10-22T19:23:08Z")

</div>

I have a large canvas and want to use the blur feature, but it’s too much for my computer to handle in real time. I only really care about the center of the canvas being blurred. (let’s say a circle with radius of 50 or a 100 x 100 square.) Can I apply the filter to just the middle of my canvas like a mask in photoshop?

Thank you! This is my first post, lmk if I should change something to fit post guidelines.

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [October 22, 2018, 7:37pm UTC](https://discourse.processing.org/t/blur-filter-only-part-of-the-image-canvas-masking/4760/2 "2018-10-22T19:37:44Z")

</div>

You can grab a PImage of the center of your sketch with get(x,y,w,h);

You can then draw that image on an off-screen PGraphics (of the same size), blur it, and mask it.

Then draw the blurred circle over the original sketch.

```java
PGraphics pg;
PImage img, msk;
size(400,400);
pg = createGraphics(200,200);
pg.beginDraw();
pg.clear();
pg.noStroke();
pg.fill(255);
pg.ellipse(100,100,175,175);
pg.endDraw();
msk = pg.get();
background(128);
for( int i = 0; i < 100; i++){
  fill(random(255),random(255),random(255));
  rect( random(width-20), random(height-20), 20, 20);
}
pg.beginDraw();
pg.image(get(100,100,200,200), 0,0);
pg.filter(BLUR,4);
pg.endDraw();
img = pg.get();
img.mask(msk);
image(img, 100, 100);

```
