We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello! Thank you for clicking my question. :-)
Do you know how to remove background of my eye animation video? I tried to save the file as alpha in After effects, but it wasn't working T.T Is there any ways that I can only remove the white color? please help me T.T....... sorry for bad English! Thank you so much! and Have a great day :-)
this photo is what i want !
PImage img;
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
Capture video;
OpenCV opencv;
Movie movie;
void setup() {
size(640, 480);
video = new Capture(this, 640/2, 480/2);
opencv = new OpenCV(this, 640/2, 480/2);
opencv.loadCascade(OpenCV.CASCADE_EYE);
video.start();
//movie
movie= new Movie(this, "eye1.mov");
movie.loop();
}
void mousePressed(){
video.stop();
}
void movieEvent(Movie m){
m.read();
}
void draw() {
scale(2);
opencv.loadImage(video);
image(video, 0, 0 );
//movie
//opencv.loadImage(movie);
//rect
noFill();
stroke(0, 255, 0);
strokeWeight(3);
//detec
Rectangle[] faces = opencv.detect();
println(faces.length);
for (int i = 0; i < faces.length; i++) {
println(faces[i].x + "," + faces[i].y);
image(movie, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
}
}
void captureEvent(Capture c) {
c.read();
}
Answers
I think it is possible using PImage's mask function:
https://processing.org/reference/PImage.html
One way to do it ( a better way could exist):
imageMask should be a copy of your image in point 1. However you will do a bit of processing on that image. You will need to do this once in setup(). The imagemask has to be change into a B&W image. Anything that is black, it will be transparent. Anything that is white it will stay. The trick is that because you mask your cam image with this imageMask, the cam image is going to have transparent regions right were your eyes are.
How to process the imageMask? You can use the filter() funtion with the THRESHOLD option: https://processing.org/reference/PImage_filter_.html with a value of 0.9 or even higher, closer to 1.0 (STEP 1) What this does is to keep your whites as white and any other color is set to black. Then you need to apply filter() again with the INVERT option(STEP 2). Then you apply the mask to the cam image(STEP 3). However there is one more detail that you need to take into account. The maskimage and you cam image have to have the same size(STEP 4). Either your maskimage needs to be combined in a larger graphics element (check createGraphics in the reference) or you will need to get a subsection of your cam image by using the get() function: https://processing.org/reference/get_.html
Sorry, a long explanation. Give it a try or even check some other "mask" posts in the forum. An example next:
https://forum.processing.org/two/discussion/comment/78559/#Comment_78559
Kf
Dear KF,
Thank you so much for your comment! I'll give it a try and leave a comment for the result ! :-)!!!!!! <3 thank you! ! ! <3
An alternative is to render your eye drawing using a Sprite library and a sprite rather than a movie file. Then transparency will be built-in automatically via your sprite sheet.