use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_ROI.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "ROI" Create Options and related options.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_ROI() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with ROI 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 SProfile.
final File outputFile1 = TestData.temp(this, "ROI-NO_ROI-.jp2", deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, "ROI-parametrized-.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
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).setClayers(20);
((JP2GDALKakaduImageWriteParam) param2).setROI("400,400,400,400");
((JP2GDALKakaduImageWriteParam) param2).setRweight(64000f);
((JP2GDALKakaduImageWriteParam) param2).setCprecincts("{256,256},{128,128},{64,64},{32,32}");
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_Qguard.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "Qguard" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_Qguard() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with Qguard 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 Qguard.
final File outputFile1 = TestData.temp(this, "Qguard1-.jp2", deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, "Qguard2-.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).setQguard(1);
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).setQguard(2);
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_Cycc.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "Cycc" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_Cycc() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with Cycc 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 ORGgen_plt.
final File outputFile1 = TestData.temp(this, "Cycc-Y-.jp2", deleteTempFilesOnExit);
final File outputFile2 = TestData.temp(this, "Cycc-N-.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).setCycc("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).setCycc("no");
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_Tiling.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "Tiling" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
@Test
public void write_Tiling() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with Tiling 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 tiling.
final int firstTilingParam = 128;
final int secondTilingParam = 256;
final String fileName1 = new StringBuffer("Tiled-").append(Integer.toString(firstTilingParam)).append("-.jp2").toString();
final String fileName2 = new StringBuffer("Tiled-").append(Integer.toString(secondTilingParam)).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).setTiling(firstTilingParam, firstTilingParam);
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).setTiling(secondTilingParam, secondTilingParam);
pbjImageWrite2.setParameter("writeParam", param2);
// Writing
final RenderedOp op2 = JAI.create("ImageWrite", pbjImageWrite2);
}
use of it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl in project imageio-ext by geosolutions-it.
the class JP2KWriteTest method write_ORGgen_tlm.
// ////////////////////////////////////////////////////////////////////////
//
// Testing "ORGgen_tlm" Create Option.
//
// ////////////////////////////////////////////////////////////////////////
// Setting this parameter requires a bit of attention. Here below, there is
// the kakadu documentation related to this paramater:
// ------------------------------------------------------------------------
// Requests the insertion of TLM (tile-part-length) marker segments in the
// main header, to facilitate random access to the code-stream. This
// attribute takes a single integer-valued parameter, which identifies the
// maximum number of tile-parts which will be written to the code-stream for
// each tile. The reason for including this parameter is that space for the
// TLM information must be reserved ahead of time; once the entire
// code-stream has been written the generation machinery goes back and
// overwrites this reserved space with actual TLM data. If the actual number
// of tile-parts which are generated is less than the value supplied here,
// empty tile-parts will be inserted into the code-stream so as to use up
// all of the reserved TLM space. For this reason, you should try to
// estimate the maximum number of tile-parts you will need as accurately as
// possible, noting that the actual value may be hard to determine ahead of
// time if incremental flushing features are to be employed. An error will
// be generated at run-time if the number of declared maximum number of
// tile-parts turns out to be insufficient.
// ------------------------------------------------------------------------
@Test
public void write_ORGgen_tlm() throws IOException, FileNotFoundException {
if (!isJp2KakDriverAvailable)
return;
LOGGER.info("Testing JP2 Write operation with ORGgen_tlm option setting");
// //
// Preparing input/output files
// //
final File inputFile = TestData.file(this, testFileName);
Assert.assertTrue(inputFile.exists());
final File outputFile1 = TestData.temp(this, "ORGgen_tlm0-.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
//
// ////////////////////////////////////////////////////////////////////
// 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).setORGgen_tlm(0);
pbjImageWrite.setParameter("writeParam", param);
}
Aggregations