Skip to main content

color JPG to bitonal TIFF slower on much faster machine

1 reply [Last post]
Joined: 2007-06-14
Points: 0


I posted this in the jai-imageio forum but am not sure if that's the correct place for it..

Here it is:

I'm doing a mass conversion from color jpg's to bitonal (monochrome) tiffs, (JAI 1.1.3 and Jai-imageio 1.1). I'm doing some benchmarks on the conversions on my local machine (P4 3.4 Ghz, 3.5 gigs of ram) and got about 1100 ms per image. I ran the same code on an AMD Opteron Quad-core 2356, 2 gigs of ram) and it ran at 1400 ms per image. I'm thinking this is not correct. On the Opteron machine when I installed the binaries I could not get the amd64 binaries to install correctly, so I installed the i586 binaries).

When I tried installing the amd64 binaries I got:

Do you agree to the above license terms? [yes or no]
./jai_imageio-1_1-lib-linux-amd64-jdk.bin: line 211: ./install.sfx.14403: cannot execute binary file

Looking on the internet I found that this was caused by cpu incompatabilities so I tried the i586.

Do you think that this is the fact that it's running so much slower? Here is the relevant conversion code:

<br />
//read jpg<br />
PlanarImage image = null;<br />
image = JAI.create("fileload", );<br />
double[][] matrix =<br />
{<br />
            {<br />
                0.114, 0.587, 0.299, 0<br />
            }<br />
        };<br />
        ParameterBlock pb = new ParameterBlock();<br />
        pb.addSource(image);<br />
        pb.add(matrix);<br />
        image = JAI.create("bandcombine", pb, null);<br />
pb = new ParameterBlock();<br />
        pb.addSource(image);<br />
        pb.add(1.0 * settings.getThreshold());<br />
        image = JAI.create("binarize", pb);<br />
//WRITE TIFF<br />
ImageWriterSpi tiffspi = new TIFFImageWriterSpi();<br />
TIFFImageWriter writer = null;</p>
<p>try<br />
{<br />
    writer = (TIFFImageWriter) tiffspi.createWriterInstance();<br />
            TIFFImageWriteParam param = new TIFFImageWriteParam(Locale.US);</p>
<p>            param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);<br />
            param.setCompressionType("CCITT T.6");</p>
<p>            OutputStream fos = new BufferedOutputStream(new FileOutputStream(outputFile));<br />
            ImageOutputStream ios = ImageIO.createImageOutputStream(fos);</p>
<p>            writer.setOutput(ios);<br />
            writer.write(null, new IIOImage(image, null, null), param);</p>
<p>            ios.flush();<br />
            writer.dispose();<br />
            ios.close();<br />
        }<br />
        catch (IOException ex)<br />
        {<br />
            Logger.getRootLogger().error(ex.getMessage(), ex);<br />
        }<br />

I'm trying to attempt this at the fastest speeds possible, if anyone knows any optimizations I can do, please let me know!

Is there any way that I can cut down this conversion?

Thanks so much

Alessandro Ferrucci

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-06-14
Points: 0

Ok, so I found out why I could not install the 64-bit binaries and why it was slower on this machine.. The OS is actually running in a 32-bit VM and it only has 1 core partitioned to it...

I still have a question as to if there is ANY way I could optimize this code to make it run faster period...are there any faster ways to binarize an image in JAI?