Indigo

Distribution

The following items are included:

Depending on the OS and architecture, proper binaries are loaded automatically.

Workflow

Imago class object represents a library instance. All operations are represented by methods of this object. Several library instances may be created within one thread to act simultaneously and independently. However, each instance requires a certain amount of memory, and thus it is recommended to have as few instances as possible.

The procedure for rendering workflow is the following:

  1. Create library instance.
  2. Load a PNG image from file or in-memory buffer
  3. Set optional parameters
  4. Set log callback, if needed
  5. Call recognize().
  6. Get the resulting molfile via getResult()

Any method of the Imago class can throw and Exception if something got wrong. The recognize() method can throw an Imago.NoResultException in case the image has failed to be recognized as a molecule.

Imago Class Public Methods

Constructor

Imago (String path);

Receives the path to Win and Linux directories containing binary modules (see distribution section above for details). E.g., if the libraries are stored in lib/Win/ and lib/Linux directories, call new Imago(“lib”). You can specify absolute paths as well.

Imago ();

Same as Imago(“lib”).

Instances are independent and are safe to be used in parallel.

Loading the Image

void loadPNG (byte[] buf);

Loads a PNG image from memory buffer.

void loadPNG (String filename);

Loads a PNG image from file.

Setting the Options

void setFilter (String filter);

void setBinarizationLevel (int level);

void setConfig (int n);

Sets one of pre-loaded configuration parameter sets. n is the index of the set, which must be nonnegative and less than the number of parameter sets, which you can know from Imago.configsCount public variable. The index of the parameter set is saved to currentConfigId public member.

Setting the Log Callback

void setLogCallback (ImagoLogCallback callback);

ImagoLogCallback is an interface defined within Imago class which has only one method:

    public interface ImagoLogCallback {
        public void log (String str);
    }

Performing the Recognition

void recognize ();

Getting the Result

string getResult ();

Returns a string with the recognized molecule in Molfile format.

An Example

   com.scitouch.Imago imago = new com.scitouch.Imago();

   imago.setLogCallback(new Imago.ImagoLogCallback() {
         public void log(String str) {
            System.out.print(str);
         }
      });

   imago.setFilter("blur");
   imago.setBinarizationLevel(150);
   imago.loadPNG("my-image.png");
   imago.recognize();
   System.out.println(imago.getResult());