0

In a part of a project, after displaying backgroundimage, I should hide part of it by creating a mask (named mask1 in my code) and making first 3000 pixels of mask1colorless. Then glare the result by utilizing blur() method of OpenCV library. The problem is that it seems that OpenCv library is ignoring opacity(alpha channel) of pixels in mask1. As a result, it is impossible to see the backgroundimage behind the blured image which has been created by OpenCV library. here is my code:

 import gab.opencv.*;
OpenCV opencv;
int[] userMap;
PImage backgroundimage,mask1;

void setup() {
backgroundimage=loadImage("test.jpg");
mask1=createImage(640,480,ARGB);
opencv = new OpenCV(this,640,480);
size(640,480);
}

void draw() {
   image(backgroundimage,0,0);
   mask1.loadPixels();

 for (int index=0; index<640*480; index++) {

        if (index<30000) {
          mask1.pixels[index]=color(0,0,0,0);
        }
        else{
         mask1.pixels[index]=color(255,255,255);
        }
    }
  mask1.updatePixels();
  opencv.loadImage(mask1);
  opencv.blur(8);
  image(opencv.getSnapshot(), 0, 0);
}

Is there any other solution to glare mask1??I have added 640*480 test.jpg to tun the above code

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
  • Please post a [mcve] instead of your entire sketch. We can't run this code. Please narrow this down to just a couple hard-coded images. Voting to close for now, but I'll vote to reopen when you edit the post to include a MCVE. – Kevin Workman Feb 25 '17 at 02:14
  • I've voted to reopen this, but you'll have better luck if you post the images so we can actually run this program. – Kevin Workman Feb 25 '17 at 20:09

0 Answers0