Skip to main content

Announcing work on jrawio 2.0

Posted by fabriziogiudici on July 30, 2009 at 4:42 AM PDT

This is a *very* preliminary post that will be followed by a more detailed document during August. But since I'm getting some feedback in private channels, I'd like to let people know what's going on.

jrawio so far has been primarily focused in decoding the raw bits from files and getting the metadata; the "reajent" component, that has got the responsibility of "developing" the raw file into a final result, has only been partially implemented and - above all - has got no quality assurance for the results - I mean, there are tests to check that a result is produced, but there's nothing about the accuracy of color rendering, etc... Furthermore, by the very nature of camera raw files, people need often to fine tune the process of "developing", as well as possibly get results "compatible" with the outcome of popular camera raw tools such as Adobe's and Apple's ones.

So, in 2.0 the most important new group of features will be "profiles". If you'd like to have a rough idea about what they are, please have a look at the issue tracker for v2.0.

Just to have a look at code, this is a preliminary code sketch that gives you a rough idea of the new Profiles API:

final ICC_Profile ADOBE_RGB = ...
       
final ProfileManager profileManager = ProfileManager.getInstance();
final Profile profile = profileManager.findProfileById("dcraw").createModifiableCopy();

profile.getOperation(WhiteBalanceOp.class).setTemperature(5500);
profile.getOperation(ColorProfileOp.class).setICCProfile(ADOBE_RGB);
profile.getOperation(DeNoiseOp.class).setAdaptivePropertiesHandler(new AdaptivePropertiesHandler<DeNoiseOp>()
  {
    @Override
    public void adaptProperties (final @Nonnull DeNoiseOp operation,
                                 final @Nonnull ImageDescriptor imageDescriptor)
      {
        final Dimension dimension = imageDescriptor.getDimension();
        final int width = dimension.width;
        final int height = dimension.height;

        operation.setAlgorithm(((width * height) >= 2 * 1024 * 1024) ? "xxx" : "yyy");
      }
  });

final Margins margins = Margins.create().withLeft(10).withRight(10).withTop(10).withBottom(10);
profile.getOperation(CropOp.class).setAdaptivePropertiesHandler(new MarginSetter().setMargins(margins));

final ImageReader reader = ImageIO.getImageReadersByFormatName("NEF").next();
BufferedImage img = reader.read(0, new RawImageReadParam(profile));

// Always read the RAW_DATA (default behaviour)
img = reader.read(0, new RawImageReadParam(SourceSelector.Source.RAW_DATA()));

// Always read the second thumbnail
img = reader.read(0, new RawImageReadParam(SourceSelector.Source.THUMBNAIL(1)));

// Read the first thumbnail if larger than 6 megapixels, the raw data instead
img = reader.read(0, new RawImageReadParam(new SourceSelector()
  {
    @Override
    public Source selectSource (@Nonnull final ImageDescriptor imageDescriptor)
      {
        final Dimension dimension = imageDescriptor.getDimension();
        final int width = dimension.width;
        final int height = dimension.height;

        return ((width * height) >= 6 * 1024 * 1024) ? Source.THUMBNAIL(0) : Source.RAW_DATA();
      }
  }));

I'm perhaps getting the interest of a couple of people that could work on the algorithmic portion of the new features (that I'm less skilled at). If you are using jrawio and are interested in these features, please let me have some feedback.

Of course, jrawio development continues as usual in the default branch, for fixing bugs and supporting more cameras, so you'll see version 1.5.1, 1.6.x and possibly 1.7.x (it depends on how long will take the creation of 2.0).