@Test public void testCompare() throws MalformedURLException, URISyntaxException { testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-lowq-jpg.test"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-lowq-jpg.test"), true ); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-lowq-png.test"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-lowq-png.test"), true); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-lowq-png.test"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-lowq-jpg.test"), true); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo.png"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo.png"), true); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo.png"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-lowq-png.test"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo.png"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-1.jpg"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo.png"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2.jpg"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo.png"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo.gif"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo.png"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-resamp-nn.png"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo.png"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-resamp-bc.png"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-noalpha.png"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2.jpg"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-noalpha.png"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-noalpha-dotted.png"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2.jpg"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-lowq-jpg.test"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2.jpg"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2-q70.jpg"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2.jpg"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2-q80.jpg"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2.jpg"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2-q90.jpg"), false); testCompareThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2.jpg"), new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-2-q95.jpg"), false); }
public CompareResult compare(DigitalObject first, DigitalObject second, List<Parameter> config) { ServicePerformanceHelper sph = new ServicePerformanceHelper(); List<PropertyComparison> props = new ArrayList<PropertyComparison>(); ServiceReport sr = null; BufferedImage i1; BufferedImage i2; try { i1 = ImageIO.read( first.getContent().getInputStream() ); i2 = ImageIO.read( second.getContent().getInputStream() ); } catch (IOException e) { return new CompareResult(null, ServiceUtils.createExceptionErrorReport("IOException reading the images. ", e)); } if( i1 == null || i2 == null ) { log.warning("One of the images was null when loaded!"); return new CompareResult(null, ServiceUtils.createErrorReport("Error reading the images, got a NULL.")); } sph.loaded(); if (i1.getWidth() != i2.getWidth() || i1.getHeight() != i2.getHeight()) { return new CompareResult(null, ServiceUtils.createErrorReport("The image dimensions must match!")); } if( i1.getColorModel().getNumComponents() != i2.getColorModel().getNumComponents()) { System.out.println("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents()); log.warning("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents()); sr = new ServiceReport(ServiceReport.Type.WARN, ServiceReport.Status.SUCCESS, "Number of colour components was not the same. The missing channels, e.g. the alpha channel, will be assumed to be zero."); } double psnr = psnr(i1, i2); props.add( buildPsnrProperty(psnr) ); if( sr == null) { sr = new ServiceReport(ServiceReport.Type.INFO, ServiceReport.Status.SUCCESS, "Comparison succeeded.", sph.getPerformanceProperties() ); } sph.stop(); return new CompareResult( props, sr ); }
JavaImageIOCompare implements Compare { public CompareResult compare(DigitalObject first, DigitalObject second, List<Parameter> config) { ServicePerformanceHelper sph = new ServicePerformanceHelper(); List<PropertyComparison> props = new ArrayList<PropertyComparison>(); ServiceReport sr = null; BufferedImage i1; BufferedImage i2; try { i1 = ImageIO.read( first.getContent().getInputStream() ); i2 = ImageIO.read( second.getContent().getInputStream() ); } catch (IOException e) { return new CompareResult(null, ServiceUtils.createExceptionErrorReport("IOException reading the images. ", e)); } if( i1 == null || i2 == null ) { log.warning("One of the images was null when loaded!"); return new CompareResult(null, ServiceUtils.createErrorReport("Error reading the images, got a NULL.")); } sph.loaded(); if (i1.getWidth() != i2.getWidth() || i1.getHeight() != i2.getHeight()) { return new CompareResult(null, ServiceUtils.createErrorReport("The image dimensions must match!")); } if( i1.getColorModel().getNumComponents() != i2.getColorModel().getNumComponents()) { System.out.println("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents()); log.warning("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents()); sr = new ServiceReport(ServiceReport.Type.WARN, ServiceReport.Status.SUCCESS, "Number of colour components was not the same. The missing channels, e.g. the alpha channel, will be assumed to be zero."); } double psnr = psnr(i1, i2); props.add( buildPsnrProperty(psnr) ); if( sr == null) { sr = new ServiceReport(ServiceReport.Type.INFO, ServiceReport.Status.SUCCESS, "Comparison succeeded.", sph.getPerformanceProperties() ); } sph.stop(); return new CompareResult( props, sr ); } }
JavaImageIOCompare implements Compare { public CompareResult compare(DigitalObject first, DigitalObject second, List<Parameter> config) { ServicePerformanceHelper sph = new ServicePerformanceHelper(); List<PropertyComparison> props = new ArrayList<PropertyComparison>(); ServiceReport sr = null; BufferedImage i1; BufferedImage i2; try { i1 = ImageIO.read( first.getContent().getInputStream() ); i2 = ImageIO.read( second.getContent().getInputStream() ); } catch (IOException e) { return new CompareResult(null, ServiceUtils.createExceptionErrorReport("IOException reading the images. ", e)); } if( i1 == null || i2 == null ) { log.warning("One of the images was null when loaded!"); return new CompareResult(null, ServiceUtils.createErrorReport("Error reading the images, got a NULL.")); } sph.loaded(); if (i1.getWidth() != i2.getWidth() || i1.getHeight() != i2.getHeight()) { return new CompareResult(null, ServiceUtils.createErrorReport("The image dimensions must match!")); } if( i1.getColorModel().getNumComponents() != i2.getColorModel().getNumComponents()) { System.out.println("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents()); log.warning("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents()); sr = new ServiceReport(ServiceReport.Type.WARN, ServiceReport.Status.SUCCESS, "Number of colour components was not the same. The missing channels, e.g. the alpha channel, will be assumed to be zero."); } double psnr = psnr(i1, i2); props.add( buildPsnrProperty(psnr) ); if( sr == null) { sr = new ServiceReport(ServiceReport.Type.INFO, ServiceReport.Status.SUCCESS, "Comparison succeeded.", sph.getPerformanceProperties() ); } sph.stop(); return new CompareResult( props, sr ); }  }
JavaImageIOCompare implements Compare { public CompareResult compare(DigitalObject first, DigitalObject second, List<Parameter> config) { ServicePerformanceHelper sph = new ServicePerformanceHelper(); List<PropertyComparison> props = new ArrayList<PropertyComparison>(); ServiceReport sr = null; BufferedImage i1; BufferedImage i2; try { i1 = ImageIO.read( first.getContent().getInputStream() ); i2 = ImageIO.read( second.getContent().getInputStream() ); } catch (IOException e) { return new CompareResult(null, ServiceUtils.createExceptionErrorReport("IOException reading the images. ", e)); } if( i1 == null || i2 == null ) { log.warning("One of the images was null when loaded!"); return new CompareResult(null, ServiceUtils.createErrorReport("Error reading the images, got a NULL.")); } sph.loaded(); if (i1.getWidth() != i2.getWidth() || i1.getHeight() != i2.getHeight()) { return new CompareResult(null, ServiceUtils.createErrorReport("The image dimensions must match!")); } if( i1.getColorModel().getNumComponents() != i2.getColorModel().getNumComponents()) { System.out.println("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents()); log.warning("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents()); sr = new ServiceReport(ServiceReport.Type.WARN, ServiceReport.Status.SUCCESS, "Number of colour components was not the same. The missing channels, e.g. the alpha channel, will be assumed to be zero."); } double psnr = psnr(i1, i2); props.add( buildPsnrProperty(psnr) ); if( sr == null) { sr = new ServiceReport(ServiceReport.Type.INFO, ServiceReport.Status.SUCCESS, "Comparison succeeded.", sph.getPerformanceProperties() ); } sph.stop(); return new CompareResult( props, sr ); }  static PropertyComparison buildPsnrProperty( double psnr ); CompareResult compare(DigitalObject first, DigitalObject second,
            List<Parameter> config); List<Parameter> convert(DigitalObject configFile); ServiceDescription describe(); static void main( String[] args ); }
JavaImageIOCompare implements Compare { public CompareResult compare(DigitalObject first, DigitalObject second, List<Parameter> config) { ServicePerformanceHelper sph = new ServicePerformanceHelper(); List<PropertyComparison> props = new ArrayList<PropertyComparison>(); ServiceReport sr = null; BufferedImage i1; BufferedImage i2; try { i1 = ImageIO.read( first.getContent().getInputStream() ); i2 = ImageIO.read( second.getContent().getInputStream() ); } catch (IOException e) { return new CompareResult(null, ServiceUtils.createExceptionErrorReport("IOException reading the images. ", e)); } if( i1 == null || i2 == null ) { log.warning("One of the images was null when loaded!"); return new CompareResult(null, ServiceUtils.createErrorReport("Error reading the images, got a NULL.")); } sph.loaded(); if (i1.getWidth() != i2.getWidth() || i1.getHeight() != i2.getHeight()) { return new CompareResult(null, ServiceUtils.createErrorReport("The image dimensions must match!")); } if( i1.getColorModel().getNumComponents() != i2.getColorModel().getNumComponents()) { System.out.println("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents()); log.warning("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents()); sr = new ServiceReport(ServiceReport.Type.WARN, ServiceReport.Status.SUCCESS, "Number of colour components was not the same. The missing channels, e.g. the alpha channel, will be assumed to be zero."); } double psnr = psnr(i1, i2); props.add( buildPsnrProperty(psnr) ); if( sr == null) { sr = new ServiceReport(ServiceReport.Type.INFO, ServiceReport.Status.SUCCESS, "Comparison succeeded.", sph.getPerformanceProperties() ); } sph.stop(); return new CompareResult( props, sr ); }  static PropertyComparison buildPsnrProperty( double psnr ); CompareResult compare(DigitalObject first, DigitalObject second,
            List<Parameter> config); List<Parameter> convert(DigitalObject configFile); ServiceDescription describe(); static void main( String[] args ); static final String NAME; static final URI PSNR_URI; }