You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Ifeanyichukwu Osuji <os...@potsdam.edu> on 2010/08/10 17:40:51 UTC

[Fwd: how to convert java program to pig UDF, and important statements in the pig script]

My java file makes use of JAI...will i be able to convert this program to
a PIG-UDF? ive tried and it keeps givin me errors. One of the errors i get
is "cannot find symbol" (symbol being the classes/methods in the same
directory).



import java.io.File;
import java.io.IOException;
import java.awt.image.RenderedImage;
import javax.imageio.ImageIO;
import javax.media.jai.JAI;

public class ImageProcessor{

    /**
*
* @param args The images to operate on
*/
    public static void main(String args[]){
        if(args.length < 1){
            System.out.println("Need a file to convert to a binary image");
            System.exit(1);
        }

        //Build up the processor
        ProcessList processor = new ProcessList();
        processor.add(new MorphologicalCloseProcess());
        processor.add(new GrayConvertProcess());
        processor.add(new MonoscaleProcess());
        processor.add(new SobelDetectionProcess());

        for(int n = 0; n < args.length; n++){
            String inputFilename = args[n];
            String outputFilename = inputFilename.substring(0,
inputFilename.lastIndexOf('.')) + "PR.jpg";

            try{
                RenderedImage inputImg = ImageIO.read(new
File(inputFilename));
                RenderedImage outputImg = processor.process(inputImg);
                ImageIO.write(outputImg, "jpg", new File(outputFilename));
            }catch(IOException e){
                System.out.println("Error writing " + outputFilename + ": "
                                    + e.getMessage());
            }
        }
    }
}




ubuntu-user
ife