@Test
 public void testEmptyFeatureVector() {
   Config config = ConfigFactory.parseString(makeConfig());
   Transform transform = TransformFactory.createTransform(config, "test_cut");
   FeatureVector featureVector = new FeatureVector();
   transform.doTransform(featureVector);
   assertTrue(featureVector.getStringFeatures() == null);
 }
  @Test
  public void testTransformLowerBoundOnly() {
    Config config = ConfigFactory.parseString(makeConfigWithLowerBoundOnly());
    Transform transform = TransformFactory.createTransform(config, "test_cut");
    FeatureVector featureVector = TransformTestingHelper.makeFeatureVector();
    transform.doTransform(featureVector);
    Map<String, Set<String>> stringFeatures = featureVector.getStringFeatures();
    assertTrue(stringFeatures.size() == 1);

    Map<String, Double> feat1 = featureVector.getFloatFeatures().get("loc");

    assertEquals(2, feat1.size());
    assertEquals(37.7, feat1.get("lat"), 0.1);
    assertEquals(40.0, feat1.get("long"), 0.1);
    assertNull(feat1.get("z"));
  }
  @Test
  public void testTransformWithNewOutput() {
    Config config = ConfigFactory.parseString(makeConfigWithOutput());
    Transform transform = TransformFactory.createTransform(config, "test_cut");
    FeatureVector featureVector = TransformTestingHelper.makeFeatureVector();
    transform.doTransform(featureVector);
    Map<String, Set<String>> stringFeatures = featureVector.getStringFeatures();
    assertTrue(stringFeatures.size() == 1);
    // original feature should not change
    Map<String, Double> feat1 = featureVector.getFloatFeatures().get("loc");
    assertEquals(3, feat1.size());
    assertEquals(37.7, feat1.get("lat"), 0.1);
    assertEquals(40.0, feat1.get("long"), 0.1);
    assertEquals(-20, feat1.get("z"), 0.1);

    // capped features are in a new feature family
    assertTrue(featureVector.getFloatFeatures().containsKey("new_output"));
    Map<String, Double> feat2 = featureVector.getFloatFeatures().get("new_output");
    assertEquals(1, feat2.size());
    assertEquals(37.7, feat2.get("lat"), 0.1);
    assertNull(feat2.get("long"));
    assertNull(feat2.get("z"));
  }
Пример #4
0
  public static void main(String args[]) {
    try {
      ICC_Profile inProfile =
          ICC_Profile.getInstance("/System/Library/ColorSync/Profiles/AdobeRGB1998.icc");
      ICC_Profile outProfile =
          ICC_Profile.getInstance("/Library/ColorSync/Profiles/CIE 1931 D50 Gamma 1.icm");

      Profile cmsOutProfile = new Profile(outProfile);
      Profile cmsInProfile = new Profile(inProfile);

      BufferedImage inputImage = ImageIO.read(new File("/Stuff/Reference/small-q60-adobergb.TIF"));
      ShortInterleavedRaster inputRaster = (ShortInterleavedRaster) inputImage.getTile(0, 0);

      ColorSpace outCS = new ICC_ColorSpace(outProfile);
      ColorModel outCM =
          new ComponentColorModel(outCS, false, false, Transparency.OPAQUE, DataBuffer.TYPE_USHORT);
      ShortInterleavedRaster outputRaster =
          (ShortInterleavedRaster)
              outCM.createCompatibleWritableRaster(inputImage.getWidth(), inputImage.getHeight());
      BufferedImage outputImage = new BufferedImage(outCM, outputRaster, false, null);

      Transform cmsTransform =
          new Transform(
              cmsInProfile, TYPE_RGB_16, cmsOutProfile, TYPE_RGB_16, INTENT_PERCEPTUAL, 0);

      cmsTransform.doTransform(inputRaster, outputRaster);

      ImageIO.write(outputImage, "TIF", new File("/Stuff/small-q60-CIED65.TIF"));

      cmsTransform.dispose();
      cmsOutProfile.dispose();
      cmsInProfile.dispose();
      // System.out.println("Profile: " + hProfile + ", " + );
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Пример #5
0
 @Override
 public void doTransform(FeatureVector featureVector) {
   for (Transform transform : transforms) {
     transform.doTransform(featureVector);
   }
 }