Hi Tilman and Andreas As we try different things I thought it good for collaboration to create a repository with the code so all can contribute.
https://github.com/kalaspuffar/ColorConvTest I've run the 3 different tests on my Machine (Thinkpad P51s) with custom Gentoo installed, if important to the conversation. I tried to invite you all as collaborators to this repository if you think this is a bad Idea let me know. Best regards Daniel On Wed, Oct 3, 2018 at 10:31 PM Andreas Lehmkuehler <[email protected]> wrote: > Am 03.10.2018 um 21:14 schrieb Daniel Persson: > > Hi Tilman > > > > Thank you for looking into this for me, I've run your code with different > > java versions and I can see the exact opposite time metrics. > > > > In my initial test Java 8 was fastest, Java 9 was slowest and 10-11 was > > somewhere in the middle. > > > > Maybe different color profiles are good at different images? > > Do you have any more suggestions? > Just a guess, but maybe you are comparing apples and oranges? It looks > like > Daniel is using Linux and AFAIK Tilman is using Windows. That could be the > reason for the different results. > > Andreas > > > I'll report these findings to Oracle tomorrow. > > > > Best regards > > Daniel > > > > $ java -jar target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar > > Raster: ByteInterleavedRaster: width = 2577 height = 1540 > #numDataElements > > 4 dataOff[0] = 0 > > 60178 > > > > $ /opt/openjdk/jdk-9.0.4/bin/java -jar > > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar > > Raster: ByteInterleavedRaster: width = 2577 height = 1540 > #numDataElements > > 4 dataOff[0] = 0 > > 33327 > > > > $ /opt/openjdk/jdk-10.0.2/bin/java -jar > > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar > > Raster: ByteInterleavedRaster: width = 2577 height = 1540 > #numDataElements > > 4 dataOff[0] = 0 > > 56596 > > > > $ /opt/openjdk/jdk-11/bin/java -jar > > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar > > Raster: ByteInterleavedRaster: width = 2577 height = 1540 > #numDataElements > > 4 dataOff[0] = 0 > > 56988 > > > > > > On Wed, Oct 3, 2018 at 8:31 PM Tilman Hausherr <[email protected]> > > wrote: > > > >> Am 03.10.2018 um 20:08 schrieb Tilman Hausherr: > >>> > >>> I could expand that one later so that it uses the raster of the actual > >>> JPEG image from your PDF. > >> > >> > >> Your JPEG file is here: > >> > >> > >> > https://drive.google.com/file/d/1HvXMet6Wygzmko9ZmY9_zlvhv72v_QHf/view?usp=sharing > >> > >> The modified code - please test on different openjdks. It took 137935 on > >> oracle jdk8. (you may want to change the "50") > >> > >> > >> > >> import java.awt.*; > >> import java.awt.color.*; > >> import java.awt.image.*; > >> import java.io.FileInputStream; > >> import javax.imageio.ImageIO; > >> import javax.imageio.ImageReadParam; > >> import javax.imageio.ImageReader; > >> import javax.imageio.stream.ImageInputStream; > >> import javax.imageio.stream.MemoryCacheImageInputStream; > >> > >> public class CConv > >> { > >> > >> static BufferedImage toRGBImageAWT(WritableRaster raster, > >> ColorSpace colorSpace) > >> { > >> > >> ColorModel colorModel = new ComponentColorModel(colorSpace, > >> false, false, Transparency.OPAQUE, > >> raster.getDataBuffer().getDataType()); > >> > >> BufferedImage src = new BufferedImage(colorModel, raster, > >> false, null); > >> BufferedImage dest = new BufferedImage(raster.getWidth(), > >> raster.getHeight(), > >> BufferedImage.TYPE_INT_RGB); > >> ColorConvertOp op = new ColorConvertOp(null); > >> //System.out.println("src="+src); > >> //System.out.println("dst="+dest); > >> op.filter(src, dest); > >> return dest; > >> } > >> > >> public static void main(String args[]) throws Exception > >> { > >> ImageReader reader = > >> ImageIO.getImageReadersByFormatName("JPEG").next(); > >> WritableRaster raster; > >> FileInputStream fis = new FileInputStream("cmyk.jpg"); > >> try (ImageInputStream iis = new > MemoryCacheImageInputStream(fis)) > >> { > >> reader.setInput(iis); > >> ImageReadParam irp = reader.getDefaultReadParam(); > >> raster = (WritableRaster) reader.readRaster(0, irp); > >> } > >> System.out.println("Raster: " + raster); > >> > >> ICC_Profile profile = > >> ICC_Profile.getInstance("ISOcoated_v2_300_bas.icc"); > >> ICC_ColorSpace colorSpace = new ICC_ColorSpace(profile); > >> long t0 = System.currentTimeMillis(); > >> for (int i = 0; i < 50; i++) > >> { > >> toRGBImageAWT(raster, colorSpace); > >> } > >> long t1 = System.currentTimeMillis(); > >> System.out.println((t1 - t0)); > >> } > >> } > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > >> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
