use of javax.media.jai.ParameterBlockJAI in project digilib by robcast.
the class JAIDocuImage method blur.
public void blur(int radius) throws ImageOpException {
RenderedImage blurredImg;
int klen = Math.max(radius, 2);
logger.debug("blur: " + klen);
int ksize = klen * klen;
float f = 1f / ksize;
float[] kern = new float[ksize];
for (int i = 0; i < ksize; i++) {
kern[i] = f;
}
KernelJAI blur = new KernelJAI(klen, klen, kern);
ParameterBlockJAI param = new ParameterBlockJAI("Convolve");
param.addSource(img);
param.setParameter("kernel", blur);
// hint with border extender
RenderingHints hint = new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_COPY));
blurredImg = JAI.create("Convolve", param, hint);
if (blurredImg == null) {
throw new ImageOpException("Unable to scale");
}
img = blurredImg;
}
use of javax.media.jai.ParameterBlockJAI in project digilib by robcast.
the class JAIDocuImage method scaleAll.
public void scaleAll(float scale) throws ImageOpException {
RenderedImage scaledImg;
// DEBUG
logger.debug("scaleAll: " + scale);
ParameterBlockJAI param = new ParameterBlockJAI("Scale");
param.addSource(img);
param.setParameter("xScale", scale);
param.setParameter("yScale", scale);
param.setParameter("interpolation", interpol);
// hint with border extender
RenderingHints hint = new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_COPY));
// scale
scaledImg = JAI.create("Scale", param, hint);
if (scaledImg == null) {
throw new ImageOpException("Unable to scale");
}
img = scaledImg;
}
use of javax.media.jai.ParameterBlockJAI in project digilib by robcast.
the class JAIDocuImage method scaleBinary.
public void scaleBinary(float scale) throws ImageOpException {
RenderedImage scaledImg;
// DEBUG
logger.debug("scaleBinary: " + scale);
ParameterBlockJAI param = new ParameterBlockJAI("SubsampleBinaryToGray");
param.addSource(img);
param.setParameter("xScale", scale);
param.setParameter("yScale", scale);
// hint with border extender
RenderingHints hint = new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_COPY));
// scale
scaledImg = JAI.create("SubsampleBinaryToGray", param, hint);
if (scaledImg == null) {
throw new ImageOpException("Unable to scale");
}
img = scaledImg;
}
use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.
the class JP2KKakaduWriteTest method testKakaduWriterParam.
public void testKakaduWriterParam() throws KduException, FileNotFoundException, IOException {
if (!isKakaduAvailable) {
LOGGER.warning("Kakadu libs not found: test are skipped ");
return;
}
if (files.length == 0) {
LOGGER.warning("No files have been specified. This test will be skipped");
return;
}
final String fileName = files[0];
// final String filePath = inputFileName + fileName;
// final File file = new File(filePath);
final File file = TestData.file(this, fileName);
final String filePath = file.getAbsolutePath();
if (!file.exists()) {
LOGGER.warning("Unable to find the file " + filePath + // + "\n Be sure you have properly specified the \"data.path\" property linking to the location where test data is available."
"\n This test will be skipped");
return;
}
final String suffix = fileName.substring(0, fileName.length() - 4);
LinkedList<TestConfiguration> configs = new LinkedList<TestConfiguration>();
JP2KKakaduImageWriteParam param = new JP2KKakaduImageWriteParam();
param.setSourceRegion(new Rectangle(100, 0, 450, 800));
param.setSourceSubsampling(2, 3, 0, 0);
configs.add(new TestConfiguration(outputFileName + "_pp_" + suffix, true, lossLessQuality, false, param));
configs.add(new TestConfiguration(outputFileName + "_pp_" + suffix, false, lossLessQuality, false, param));
configs.add(new TestConfiguration(outputFileName + "_pp_" + suffix, true, lossyQuality, false, param));
configs.add(new TestConfiguration(outputFileName + "_pp_" + suffix, false, lossyQuality, false, param));
configs.add(new TestConfiguration(outputFileName + "_pp_JAI_" + suffix, true, lossLessQuality, true, param));
configs.add(new TestConfiguration(outputFileName + "_pp_JAI_" + suffix, false, lossLessQuality, true, param));
for (TestConfiguration config : configs) {
final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
ImageReader reader = ImageIO.getImageReaders(ImageIO.createImageInputStream(file)).next();
pbjImageRead.setParameter("reader", reader);
pbjImageRead.setParameter("Input", file);
RenderedOp image = JAI.create("ImageRead", pbjImageRead);
write(config.outputFileName, image, config.writeCodeStreamOnly, config.quality, config.useJAI, config.param);
}
}
use of javax.media.jai.ParameterBlockJAI in project imageio-ext by geosolutions-it.
the class JP2KakaduReadTest method jaiReadFromFile.
@org.junit.Test
public void jaiReadFromFile() throws IOException {
if (!runTests)
return;
final File file = TestData.file(this, "CB_TM432.jp2");
ImageReadDescriptorMT.register(JAI.getDefaultInstance());
final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageReadMT");
ImageLayout l = new ImageLayout();
l.setTileHeight(256);
l.setTileWidth(256);
JP2KKakaduImageReadParam rp = new JP2KKakaduImageReadParam();
rp.setSourceSubsampling(1, 1, 0, 0);
rp.setSourceRegion(new Rectangle(10, 10, 200, 200));
rp.setInterpolationType(JP2KKakaduImageReadParam.INTERPOLATION_BILINEAR);
rp.setQualityLayers(2);
pbjImageRead.setParameter("ReadParam", rp);
pbjImageRead.setParameter("Input", file);
pbjImageRead.setParameter("imageChoice", 0);
RenderedOp image = JAI.create("ImageReadMT", pbjImageRead, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));
if (TestData.isInteractiveTest())
ImageIOUtilities.visualize(image);
else
Assert.assertNotNull(image.getTiles());
}
Aggregations