00001 package testbench;
00002
00003 import java.io.File;
00004 import java.io.FileNotFoundException;
00005
00006 import jj2000.j2k.decoder.CmdLnDecoder;
00007 import jj2000.j2k.encoder.CmdLnEncoder;
00008
00009 import commandline.Encoder.Iterators.RateDistorion;
00010 import commandline.TxTPackage.DirectoryAndFileClass;
00011 import commandline.debuggingCode.Debug;
00012
00013
00014 public class JPEGRateDistortion extends RateDistorion {
00015
00016
00017 public JPEGRateDistortion(File file,String path_to_original_fig,String path_to_out_dir) {
00018 super(file, path_to_original_fig, path_to_out_dir);
00019
00020 }
00021
00022 protected String getCompressionType(){
00023 return "2000";
00024 }
00025
00026 protected void initType(){
00027 this.type="jpeg";
00028 }
00029
00030 protected String getCompressionName(){
00031 return "JPEG200O-compression";
00032 }
00033
00034 public void makeRateDistortionFile() throws FileNotFoundException{
00035 super.makeRateDistortionFile("pgm","j2k");
00036 }
00037
00038
00039 public void createImages(float beginrate , float steprate, float endrate){
00040 String encodingcommand[],decodingcommand[];
00041 String outputFilename;
00042 for(float rate=beginrate;rate<endrate;rate+=steprate){
00043 outputFilename=""+ path_to_out_dir+File.separator + (int)Math.round(rate*1000) +".j2k";
00044 encodingcommand=new String[]{"-i", ""+path_to_original_fig,"-o" ,outputFilename, "-rate",""+ rate};
00045
00046 for (String s:encodingcommand){
00047 Debug.print(s);}
00048
00049
00050 CmdLnEncoder.main(encodingcommand);
00051 decodingcommand=new String[]{"-i",outputFilename,"-o",super.getFileWithOtherExtention(new File(outputFilename),"pgm").getAbsolutePath()};
00052 CmdLnDecoder.main(decodingcommand);
00053 }
00054 }
00055
00056
00057 public static void parameterPerform(String image_name, float beginrate,float eindrate) throws FileNotFoundException {
00058 String s=File.separator;
00059 String path_output_dir=Paths.pathToRateDistortionOutput+s+"jpeg_"+image_name;
00060
00061 DirectoryAndFileClass.makeDir(path_output_dir);
00062
00063
00064
00065
00066 String path_original=Paths.getPathToImageDB()+s+image_name+".pgm";
00067 Debug.print(path_original);
00068 Debug.print(path_output_dir);
00069
00070 JPEGRateDistortion rateDistortion=
00071 new JPEGRateDistortion(new File(Paths.pathToRateDistortionOutput+s+ image_name+"rate_distortion_jpeg_2000.m"),path_original,path_output_dir);
00072 float step=(eindrate-beginrate)/50;
00073 rateDistortion.createImages(beginrate,step,eindrate);
00074 rateDistortion.makeRateDistortionFile();
00075 Debug.print("JPEGRATEDISTORTION- Job done. System will now exit.");
00076
00077
00078 }
00079
00080 }