Chroma key

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lambeau86
    New Member
    • Mar 2008
    • 1

    Chroma key

    Hi, I'm new to java and I'm trying to get my program to run where it takes one photo of me at a green screen and then substitutes it for another background.

    I have all the code that grabs the pictures but I cant quite get it to work correctly. My code so far is as follows;


    Code:
    public class DIP {
    public static void chromakey(Picture p1, Picture p2){
    		for( int i = 0, j = p1.getHeight()-1; i < p1.getWidth(); i++){
    			for( int k = 0, l= p2.getHeight(); k < p2.getWidth()-1; k++){
    
    				int g1 = p1.getGreen(i, j);
    
    				while (g1 > 180 && g1 < 190)
    				i=k;
    				j=l;
    				
    				
    				
    				
    					
    			}}}
    	public static void main(String[] args) {
    		
    		
    		// Choose a file from the filesystem
    		ImageFileChooser ifc = new ImageFileChooser();
    		String filename = ifc.getFile();
    		
    		// Create a Picture object
    		Picture original = new Picture(filename, "Original Image");
    		Picture chrom = new Picture(filename, "Chromakey");
    		
    		// Show the Picture
    		original.displayImage();
    		
    		
    		// Convert Picture to chromakey
    		System.out.println("Converting to chromakey.");
    		String filename2 = ifc.getFile();
    		Picture background = new Picture(filename2, "");
    		chromakey(chrom,background);
    		chrom.displayImage();
    		
    		
    	}}
Working...