import java.awt.event.MouseEvent; public class RemoveBackground extends PixelOperater{ int[] backgroundPixelArray ; RemoveBackground(){ super(); setTitle("RemoveBackground"); grabBackground(); } public void grabBackground(){ backgroundPixelArray = (int[]) ps.getPixelArray().clone(); } public static void main(String[] args){ RemoveBackground br = new RemoveBackground(); br.startVideo(); } public void performPixelOp(int _x, int _y){ int[] rgb = ps.getPixel(_x,_y); int[] brgb = ps.getPixel(backgroundPixelArray,_x,_y); int diff = Math.abs(rgb[1]-brgb[1]) +Math.abs(rgb[2]-brgb[2])+Math.abs(rgb[3]-brgb[3]); if (diff < threshold){ ps.setPixel(_x,_y,255,0,0,0); } } public void mouseReleased(MouseEvent e) { grabBackground(); } }