javaopenimaj

OpenImaj AdaptiveLocalThresholdContrast null pointer exception


I'm trying to learn how to use OpenImaj's AdaptiveLocalThresholdContrast thresholder to process an image into two "segments" and then view the processed image. When I run the following code:

AdaptiveLocalThresholdContrast thresholder = new AdaptiveLocalThresholdContrast(10);
MBFImage input = ImageUtilities.readMBF(new File("/path/to/file.jpg"));
FImage flat = input.flatten();
DisplayUtilities.display(flat);
thresholder.processImage(flat);
DisplayUtilities.display(flat);

The original (flattened) image is displayed, and then I get the following null pointer exception at the line thresholder.processImage(flat):

Exception in thread "main" java.lang.NullPointerException
at org.openimaj.image.processing.threshold.AdaptiveLocalThresholdContrast.processImage(AdaptiveLocalThresholdContrast.java:74)

I looked at the source code for AdaptiveLocalThresholdContrast at line 74, but it's not clear to me what's causing the null pointer exception. Any help would be greatly appreciated.

http://www.openimaj.org/openimaj-image/image-processing/xref/org/openimaj/image/processing/threshold/AdaptiveLocalThresholdContrast.html


Solution

  • Hmm, that's a bug (probably a result of a refactoring at some point - sorry). Should now be fixed in the source (https://github.com/openimaj/openimaj/commit/2f247e4ab0f7da02713e8545d4ac153aa08070b8) & also available in the latest "1.4-SNAPSHOT" version of the jars.