Search in sources :

Example 56 with ParameterBlockJAI

use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.

the class JP2KWriteTest method write_Qstep.

// ////////////////////////////////////////////////////////////////////////
// 
// Testing "Qstep" Create Option.
// 
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_Qstep() throws IOException, FileNotFoundException {
    if (!isJp2KakDriverAvailable)
        return;
    LOGGER.info("Testing JP2 Write operation with Qstep option setting");
    // //
    // Preparing input/output files
    // //
    final File inputFile = TestData.file(this, testFileName);
    Assert.assertTrue(inputFile.exists());
    // Output files resulting from 3 different values of the same create
    // option. In this test, the create option is Qstep.
    final float firstQstepParam = 0.2f;
    final float secondQstepParam = 1.7f;
    final String fileName1 = new StringBuffer("Qstep-").append(Float.toString(firstQstepParam)).append("f-.jp2").toString();
    final String fileName2 = new StringBuffer("Qstep-").append(Float.toString(secondQstepParam)).append("f-.jp2").toString();
    final String fileName3 = "Qstep-Default-.jp2";
    final File outputFile1 = TestData.temp(this, fileName1, deleteTempFilesOnExit);
    final File outputFile2 = TestData.temp(this, fileName2, deleteTempFilesOnExit);
    final File outputFile3 = TestData.temp(this, fileName3, deleteTempFilesOnExit);
    // //
    // Preparing to read
    // //
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    if (ENABLE_SUBSAMPLING) {
        ImageReadParam readParam = new ImageReadParam();
        readParam.setSourceSubsampling(4, 4, 0, 0);
        pbjImageRead.setParameter("readParam", readParam);
    }
    pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (1ST version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile1));
    ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite.setParameter("Writer", writer);
    // Specifying image source to write
    pbjImageWrite.addSource(image);
    ImageWriteParam param = writer.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param).setQstep(firstQstepParam);
    pbjImageWrite.setParameter("writeParam", param);
    // Writing
    final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (2ND version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite2 = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite2.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile2));
    ImageWriter writer2 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite2.setParameter("Writer", writer2);
    // Specifying image source to write
    pbjImageWrite2.addSource(image);
    ImageWriteParam param2 = writer2.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param2).setQstep(secondQstepParam);
    pbjImageWrite2.setParameter("writeParam", param2);
    // Writing
    final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (3ND version of the create option - DEFAULT)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite3 = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite3.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile3));
    ImageWriter writer3 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite3.setParameter("Writer", writer3);
    // Specifying image source to write
    pbjImageWrite3.addSource(image);
    ImageWriteParam param3 = writer3.getDefaultWriteParam();
    // Specifying the required create option
    pbjImageWrite3.setParameter("writeParam", param3);
    // Writing
    final RenderedOp op3 = JAI.create("ImageWrite", pbjImageWrite3);
}
Also used : ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ImageWriter(javax.imageio.ImageWriter) FileImageOutputStreamExtImpl(it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl) ImageWriteParam(javax.imageio.ImageWriteParam) ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) File(java.io.File) Test(org.junit.Test)

Example 57 with ParameterBlockJAI

use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.

the class JP2KWriteTest method write_ORGtparts.

// ////////////////////////////////////////////////////////////////////////
// 
// Testing "ORGtparts" Create Option.
// 
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_ORGtparts() throws IOException, FileNotFoundException {
    if (!isJp2KakDriverAvailable)
        return;
    LOGGER.info("Testing JP2 Write operation with ORGtparts option setting");
    // //
    // Preparing input/output files
    // //
    final File inputFile = TestData.file(this, testFileName);
    Assert.assertTrue(inputFile.exists());
    // //
    // Preparing to read
    // //
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    if (ENABLE_SUBSAMPLING) {
        ImageReadParam readParam = new ImageReadParam();
        readParam.setSourceSubsampling(8, 8, 0, 0);
        pbjImageRead.setParameter("readParam", readParam);
    }
    pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (i-TH version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    final String[] createVersions = { "R", "C", "L", "R|C", "R|L", "L|C", "R|L|C" };
    final String[] filenameVersions = { "R", "C", "L", "RC", "RL", "LC", "RLC" };
    final int numberOfVersions = createVersions.length;
    for (int i = 0; i < numberOfVersions; i++) {
        // Output files resulting from different values of the same create
        // option. In this test, the create option is ORGtparts.
        final String filenameVersion = filenameVersions[i];
        final StringBuffer fileName = new StringBuffer("ORGtparts").append(filenameVersion).append("-.jp2");
        final File outputFile = TestData.temp(this, fileName.toString(), deleteTempFilesOnExit);
        // Setting output and writer
        final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
        pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile));
        ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
        pbjImageWrite.setParameter("Writer", writer);
        // Specifying image source to write
        pbjImageWrite.addSource(image);
        ImageWriteParam param = writer.getDefaultWriteParam();
        // Specifying the required create option
        ((JP2GDALKakaduImageWriteParam) param).setORGgen_plt("yes");
        ((JP2GDALKakaduImageWriteParam) param).setLayers(10);
        ((JP2GDALKakaduImageWriteParam) param).setCorder("LRCP");
        ((JP2GDALKakaduImageWriteParam) param).setTiling(1024, 1024);
        ((JP2GDALKakaduImageWriteParam) param).setORGtparts(createVersions[i]);
        pbjImageWrite.setParameter("writeParam", param);
        // Writing
        final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
    }
}
Also used : ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ImageWriter(javax.imageio.ImageWriter) FileImageOutputStreamExtImpl(it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl) ImageWriteParam(javax.imageio.ImageWriteParam) ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) File(java.io.File) Test(org.junit.Test)

Example 58 with ParameterBlockJAI

use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.

the class JP2KWriteTest method write_Cmodes.

// ////////////////////////////////////////////////////////////////////////
// 
// Testing "CModes" Create Option.
// 
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_Cmodes() throws IOException, FileNotFoundException {
    if (!isJp2KakDriverAvailable)
        return;
    LOGGER.info("Testing JP2 Write operation with CModes option setting");
    // //
    // Preparing input/output files
    // //
    final File inputFile = TestData.file(this, testFileName);
    Assert.assertTrue(inputFile.exists());
    // //
    // Preparing to read
    // //
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    if (ENABLE_SUBSAMPLING) {
        ImageReadParam readParam = new ImageReadParam();
        readParam.setSourceSubsampling(4, 4, 0, 0);
        pbjImageRead.setParameter("readParam", readParam);
    }
    pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (i-TH version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    final String[] createVersions = { "BYPASS", "BYPASS|RESTART|CAUSAL", "RESTART|ERTERM", "RESET" };
    final String[] filenameVersions = { "BYPASS", "BYPASSRESTARTCAUSAL", "RESTARTERTERM", "RESET" };
    final int numberOfVersions = createVersions.length;
    for (int i = 0; i < numberOfVersions; i++) {
        // Output files resulting from different values of the same create
        // option. In this test, the create option is ORGtparts.
        final String filenameVersion = filenameVersions[i];
        final StringBuffer fileName = new StringBuffer("CModes").append(filenameVersion).append(".jp2");
        final File outputFile = TestData.temp(this, fileName.toString(), deleteTempFilesOnExit);
        // Setting output and writer
        final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
        pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile));
        ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
        pbjImageWrite.setParameter("Writer", writer);
        // Specifying image source to write
        pbjImageWrite.addSource(image);
        ImageWriteParam param = writer.getDefaultWriteParam();
        // Specifying the required create option
        ((JP2GDALKakaduImageWriteParam) param).setCmodes(createVersions[i]);
        pbjImageWrite.setParameter("writeParam", param);
        // Writing
        final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
    }
}
Also used : ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ImageWriter(javax.imageio.ImageWriter) FileImageOutputStreamExtImpl(it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl) ImageWriteParam(javax.imageio.ImageWriteParam) ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) File(java.io.File) Test(org.junit.Test)

Example 59 with ParameterBlockJAI

use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.

the class JP2KWriteTest method write_Clevels.

// ////////////////////////////////////////////////////////////////////////
// 
// Testing "Clevels" Create Option.
// 
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_Clevels() throws IOException, FileNotFoundException {
    if (!isJp2KakDriverAvailable)
        return;
    LOGGER.info("Testing JP2 Write operation with Clevels option setting");
    // //
    // Preparing input/output files
    // //
    final File inputFile = TestData.file(this, testFileName);
    Assert.assertTrue(inputFile.exists());
    // Output files resulting from 2 different values of the same create
    // option. In this test, the create option is Clevels.
    final int firstClevelsParam = 2;
    final int secondClevelsParam = 6;
    final String fileName1 = new StringBuffer("Clevels-").append(Integer.toString(firstClevelsParam)).append("-.jp2").toString();
    final String fileName2 = new StringBuffer("Clevels-").append(Integer.toString(secondClevelsParam)).append("-.jp2").toString();
    final File outputFile1 = TestData.temp(this, fileName1, deleteTempFilesOnExit);
    final File outputFile2 = TestData.temp(this, fileName2, deleteTempFilesOnExit);
    // //
    // Preparing to read
    // //
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    if (ENABLE_SUBSAMPLING) {
        ImageReadParam readParam = new ImageReadParam();
        readParam.setSourceSubsampling(4, 4, 0, 0);
        pbjImageRead.setParameter("readParam", readParam);
    }
    // Reading
    pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (1ST version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile1));
    ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite.setParameter("Writer", writer);
    // Specifying image source to write
    pbjImageWrite.addSource(image);
    ImageWriteParam param = writer.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param).setClevels(firstClevelsParam);
    pbjImageWrite.setParameter("writeParam", param);
    // Writing
    final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (2ND version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite2 = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite2.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile2));
    ImageWriter writer2 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite2.setParameter("Writer", writer2);
    // Specifying image source to write
    pbjImageWrite2.addSource(image);
    ImageWriteParam param2 = writer2.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param2).setClevels(secondClevelsParam);
    pbjImageWrite2.setParameter("writeParam", param2);
    // Writing
    final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
Also used : ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ImageWriter(javax.imageio.ImageWriter) FileImageOutputStreamExtImpl(it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl) ImageWriteParam(javax.imageio.ImageWriteParam) ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) File(java.io.File) Test(org.junit.Test)

Example 60 with ParameterBlockJAI

use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.

the class JP2KWriteTest method write_FLUSH.

// ////////////////////////////////////////////////////////////////////////
// 
// Testing "FLUSH" Create Option.
// 
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_FLUSH() throws IOException, FileNotFoundException {
    if (!isJp2KakDriverAvailable)
        return;
    LOGGER.info("Testing JP2 Write operation with FLUSH option setting");
    // //
    // Preparing input/output files
    // //
    final File inputFile = TestData.file(this, testFileName);
    Assert.assertTrue(inputFile.exists());
    // Output files resulting from 2 different values of the same create
    // option. In this test, the create option is FLUSH.
    final File outputFile1 = TestData.temp(this, "FLUSH-.jp2", deleteTempFilesOnExit);
    final File outputFile2 = TestData.temp(this, "NO-FLUSH-.jp2", deleteTempFilesOnExit);
    // //
    // Preparing to read
    // //
    final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", inputFile);
    if (ENABLE_SUBSAMPLING) {
        ImageReadParam readParam = new ImageReadParam();
        readParam.setSourceSubsampling(4, 4, 0, 0);
        pbjImageRead.setParameter("readParam", readParam);
    }
    pbjImageRead.setParameter("Reader", new JP2GDALKakaduImageReaderSpi().createReaderInstance());
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (1ST version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile1));
    ImageWriter writer = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite.setParameter("Writer", writer);
    // Specifying image source to write
    pbjImageWrite.addSource(image);
    ImageWriteParam param = writer.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param).setFlush("YES");
    pbjImageWrite.setParameter("writeParam", param);
    // Writing
    final RenderedOp op = JAI.create("ImageWrite", pbjImageWrite);
    // ////////////////////////////////////////////////////////////////////
    // 
    // preparing to write (2ND version of the create option test)
    // 
    // ////////////////////////////////////////////////////////////////////
    // Setting output and writer
    final ParameterBlockJAI pbjImageWrite2 = new ParameterBlockJAI("ImageWrite");
    pbjImageWrite2.setParameter("Output", new FileImageOutputStreamExtImpl(outputFile2));
    ImageWriter writer2 = new JP2GDALKakaduImageWriterSpi().createWriterInstance();
    pbjImageWrite2.setParameter("Writer", writer2);
    // Specifying image source to write
    pbjImageWrite2.addSource(image);
    ImageWriteParam param2 = writer2.getDefaultWriteParam();
    // Specifying the required create option
    ((JP2GDALKakaduImageWriteParam) param2).setFlush("NO");
    pbjImageWrite2.setParameter("writeParam", param2);
    // Writing
    final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
Also used : ImageReadParam(javax.imageio.ImageReadParam) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) ImageWriter(javax.imageio.ImageWriter) FileImageOutputStreamExtImpl(it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl) ImageWriteParam(javax.imageio.ImageWriteParam) File(java.io.File) Test(org.junit.Test)

Aggregations

ParameterBlockJAI (javax.media.jai.ParameterBlockJAI)76 File (java.io.File)71 RenderedOp (javax.media.jai.RenderedOp)71 Test (org.junit.Test)57 ImageReadParam (javax.imageio.ImageReadParam)48 AbstractGDALTest (it.geosolutions.imageio.gdalframework.AbstractGDALTest)32 ImageWriter (javax.imageio.ImageWriter)28 ImageLayout (javax.media.jai.ImageLayout)26 ImageWriteParam (javax.imageio.ImageWriteParam)23 RenderingHints (java.awt.RenderingHints)22 FileImageOutputStreamExtImpl (it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl)20 FileNotFoundException (java.io.FileNotFoundException)13 ImageReader (javax.imageio.ImageReader)13 Rectangle (java.awt.Rectangle)9 IIOMetadata (javax.imageio.metadata.IIOMetadata)5 FileImageInputStreamExtImpl (it.geosolutions.imageio.stream.input.FileImageInputStreamExtImpl)3 ColorSpace (java.awt.color.ColorSpace)3 ColorModel (java.awt.image.ColorModel)3 RenderedImage (java.awt.image.RenderedImage)3 SampleModel (java.awt.image.SampleModel)3