Package ucar.jpeg.jj2000.j2k.image

Examples of ucar.jpeg.jj2000.j2k.image.Tiler


        int trefy = j2kwparam.getTileGridYOffset();
        if (trefx < 0 || trefy < 0 || trefx > refx || trefy > refy)
            throw new IIOException(I18N.getString("J2KImageWriter4"));

        // Instantiate tiler
        Tiler imgtiler = new Tiler(imgsrc,refx,refy,trefx,trefy,tw,th);

        // Creates the forward component transform
        ForwCompTransf fctransf = new ForwCompTransf(imgtiler, j2kwparam);

        // Creates ImgDataConverter
        ImgDataConverter converter = new ImgDataConverter(fctransf);

        // Creates ForwardWT (forward wavelet transform)
        ForwardWT dwt = ForwardWT.createInstance(converter, j2kwparam);

        // Creates Quantizer
        Quantizer quant = Quantizer.createInstance(dwt,j2kwparam);

        // Creates ROIScaler
        ROIScaler rois = ROIScaler.createInstance(quant, j2kwparam);

        // Creates EntropyCoder
        EntropyCoder ecoder =
      EntropyCoder.createInstance(rois, j2kwparam,
    j2kwparam.getCodeBlockSize(),
    j2kwparam.getPrecinctPartition(),
    j2kwparam.getBypass(),
    j2kwparam.getResetMQ(),
    j2kwparam.getTerminateOnByte(),
    j2kwparam.getCausalCXInfo(),
    j2kwparam.getCodeSegSymbol(),
    j2kwparam.getMethodForMQLengthCalc(),
    j2kwparam.getMethodForMQTermination());

        // Rely on rate allocator to limit amount of data
        File tmpFile = File.createTempFile("jiio-", ".tmp");
        tmpFile.deleteOnExit();

        // Creates CodestreamWriter
        FileCodestreamWriter bwriter =
            new FileCodestreamWriter(tmpFile, Integer.MAX_VALUE);

        // Creates the rate allocator
        float rate = (float)j2kwparam.getEncodingRate();
        PostCompRateAllocator ralloc =
            PostCompRateAllocator.createInstance(ecoder,
                                                 rate,
                                                 bwriter,
                                                 j2kwparam);

        // Instantiates the HeaderEncoder
        HeaderEncoder headenc =
            new HeaderEncoder(imgsrc, imsigned, dwt, imgtiler,
                              j2kwparam, rois,ralloc);

        ralloc.setHeaderEncoder(headenc);

        // Writes header to be able to estimate header overhead
        headenc.encodeMainHeader();

        //Initializes rate allocator, with proper header
        // overhead. This will also encode all the data
        try {
            ralloc.initialize();
        } catch (RuntimeException e) {
            if (WRITE_ABORTED.equals(e.getMessage())) {
                bwriter.close();
                tmpFile.delete();
                processWriteAborted();
                return;
            } else throw e;
        }

        // Write header (final)
        headenc.reset();
        headenc.encodeMainHeader();

        // Insert header into the codestream
        bwriter.commitBitstreamHeader(headenc);

        // Now do the rate-allocation and write result
        ralloc.runAndWrite();

        //Done for data encoding
        bwriter.close();

        // Calculate file length
        int fileLength = bwriter.getLength();

        // Tile-parts and packed packet headers
        int pktspertp = j2kwparam.getPacketPerTilePart();
        int ntiles = imgtiler.getNumTiles();
        if (pktspertp>0 || pphTile || pphMain){
            CodestreamManipulator cm =
                new CodestreamManipulator(tmpFile, ntiles, pktspertp,
                                          pphMain, pphTile, tempSop,
                                          tempEph);
View Full Code Here


    int E = drs.getBinaryScaleFactor();
    //System.out.println( "DS E=" + E );
    float EE = (float) java.lang.Math.pow((double) 2.0, (double) E);
    //System.out.println( "DS EE=" + EE );

    Grib2JpegDecoder g2j = null;
    int numberPoints = 0;
    try {
      if (nb != 0) {  // there's data to decode
        String[] argv = new String[4];
        argv[0] = "-rate";
        argv[1] = Integer.toString(nb);
        argv[2] = "-verbose";
        argv[3] = "off";
        //argv[ 4 ] = "-debug" ;
        //argv[ 2 ] = "-nocolorspace" ;
        //argv[ 3 ] = "-Rno_roi" ;
        //argv[ 4 ] = "-cdstr_info" ;
        //argv[ 5 ] = "-verbose" ;
        g2j = new Grib2JpegDecoder(argv);
        // how jpeg2000.jar use to decode, used raf
        //g2j.decode(raf, length - 5);
        // jpeg-1.0.jar added method to have the data read first
        byte[] buf = new byte[ length - 5 ];
        raf.read( buf );
        g2j.decode( buf );
      }
      numberPoints = gds.getGdsVars().getNumberPoints();
      //System.out.println( "DS GDS NumberPoints=" +  gds.getNumberPoints() );
      data = new float[numberPoints];
      boolean[] bitmap = bms.getBitmap();
View Full Code Here

        float [][] out = new float [3][];
        float [][] in  = new float [3][];

        for (i=0;i<3;++i) {
            in[i= inblk [i] .getDataFloat();
            outblk[i] = new DataBlkFloat ();
            copyGeometry (outblk[i],inblk[i]);
            outblk[i].offset = inblk[i].offset;
            out[i] = new float [length];
            outblk[i].setData (out[i]); }
View Full Code Here

        int [][] out = new int [3][];
        int [][] in  = new int [3][];

        for (i=0;i<3;++i) {
            in[i= inblk [i] .getDataInt();
            outblk[i] = new DataBlkInt ();
            copyGeometry (outblk[i],inblk[i]);
            outblk[i].offset = inblk[i].offset;
            out[i] = new int [length];
            outblk[i].setData (out[i]); }
View Full Code Here

TOP

Related Classes of ucar.jpeg.jj2000.j2k.image.Tiler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.