Mask with blur border
in
Programming Questions
•
1 year ago
Hi everybody!
I'm doing a code to color a b/w image. I used a mask but I would like to simulate a brush effect, so I need something as a blur effect to add on the outline of the mask...do you think it is possible? Somebody know how can I do?
this is the code I'm using:
I'm doing a code to color a b/w image. I used a mask but I would like to simulate a brush effect, so I need something as a blur effect to add on the outline of the mask...do you think it is possible? Somebody know how can I do?
this is the code I'm using:
PImage img1;
PImage niceImage;
PImage maskedImage;
PGraphics graphicalMask;
int iw, ih;
int dw, dh;
void setup()
{
size(864, 499);
img1 = loadImage("bw.jpg");
niceImage = loadImage("animalcreation.jpg");
iw = niceImage.width;
ih = niceImage.height;
dw = width - iw;
dh = height - ih;
graphicalMask = createGraphics(iw, ih, JAVA2D);
}
void draw() {
background(img1);
// Copy the original image (kept as reference)
maskedImage = niceImage.get();
// Apply the mask
maskedImage.mask(graphicalMask);
// Display the result
image(maskedImage, dw/2, dh/2);
}
void mouseDragged() {
graphicalMask.beginDraw();
graphicalMask.noStroke();
// Draw the mask, depending on mouse position
int x = mouseX - dw/2;
int y = mouseY - dh/2;
// An ellipse to see a good part of the image
graphicalMask.ellipse(x, y, 30, 30);
}
1