00001 package commandline.JUnitTest.EncodingDecoding;
00002
00003
00004 import java.io.File;
00005 import java.io.FileNotFoundException;
00006
00007 import junit.framework.TestCase;
00008 import testbench.Paths;
00009
00010 import commandline.Decoder.NormalMeshDecoder;
00011 import commandline.Encoder.EncoderTypeSelector;
00012 import commandline.Encoder.NormalMeshEncoder;
00013 import commandline.Encoder.Timer;
00014 import commandline.Encoder.Iterators.MeshIteratorSelector;
00015 import commandline.ImageStuff.GeometricObjects.factories.EdgeConstructorTriangleMakerFactory;
00016 import commandline.ImageStuff.GeometricObjects.factories.GenericEdgeConstructorTriangleMakerFactory;
00017 import commandline.ImageStuff.Topology.ConnectionCriteriumSelector;
00018 import commandline.ImageTools.ImageViewer;
00019 import commandline.Norm.NormenMaker;
00020 import commandline.debuggingCode.Debug;
00021 import commandline.factories.SnijPixelStrategyBuilder;
00027 public class TestEncoderDecoder extends TestCase {
00028
00029
00030 public void testCoderDecoder() throws FileNotFoundException{
00031
00032
00033 String s =File.separator;
00034 String image_name="struve";
00035
00036
00037
00038 int PSNR=50;
00039 String path_to_original_fig=Paths.getPathToImageDB()+s+image_name+".bmp";
00040
00041 int COMPRESSIONTYPE=EncoderTypeSelector.GENERIC_COMPRESSION;
00042 String path_to_out_dir="E:"+s+ "subversion_sandbox"+s+ "NODICVI"+s+"output"+s;
00043 int ORDERING_NORM=NormenMaker.L_2;
00044 int TESSELATION_NORM=NormenMaker.L_1;
00045
00046 String[] command=new String[]{
00047 "-i", ""+path_to_original_fig,
00048 "-o" ,""+ path_to_out_dir,
00049 "-n", ""+image_name+"",
00050 "-IT",""+MeshIteratorSelector.UNTIL_NUMBER_OF_TRIANGLES_REACHED,
00051 "-stop",""+ 30000,
00052 "-snij",""+SnijPixelStrategyBuilder.PIERCING_WAARDE_TYPE,
00053 "-Con",""+ConnectionCriteriumSelector.CONVEX_CONNECTION_CRITERIUM,
00054
00055 "-compressiontype", EncoderTypeSelector.getNameForCompressionType(COMPRESSIONTYPE),
00056 "-maxr","12",
00057 "-Wnr",""+ORDERING_NORM,
00058 "-Wnt",""+TESSELATION_NORM
00059 };
00060
00061
00062 NormalMeshEncoder normalMeshEncoder=null;
00063 try {
00064 Timer t= new Timer();
00065 t.tic();
00066 normalMeshEncoder = NormalMeshEncoder.commandline(command);
00067 System.out.println(t.tac());
00068 } catch (FileNotFoundException e) {
00069 e.printStackTrace();
00070 }
00071 String path_to_compressed_file=normalMeshEncoder.getConfiguration().getOutputDir()+normalMeshEncoder.getConfiguration().getOutputName()+".nob";
00072 Debug.print("File size = "+ new File(path_to_compressed_file).length());
00073
00074
00075
00076 ImageViewer imageViewer=new ImageViewer();
00077 imageViewer.show(normalMeshEncoder.getTriangleStorage().getFullGrayImage().getBufferedImage().getRaster(),"reconstructed");
00078
00079
00080
00081 EdgeConstructorTriangleMakerFactory constructorTriangleMakerFactory=new GenericEdgeConstructorTriangleMakerFactory();
00082 NormalMeshDecoder meshDecoder=new NormalMeshDecoder(path_to_compressed_file,constructorTriangleMakerFactory);
00083 meshDecoder.perform();
00084 ImageViewer imageViewer2=new ImageViewer();
00085 imageViewer2.show(meshDecoder.getTriangleStorage().getFullGrayImage().getBufferedImage().getRaster(),"reconstructed from decoded stream");
00086 }
00087
00088 public static void main(String args[]) throws FileNotFoundException{
00089 TestEncoderDecoder testEncoderDecoder=new TestEncoderDecoder();
00090 testEncoderDecoder.testCoderDecoder();
00091 }
00092
00093 }