NullPointer exception when using differenceColor plugin (as indicated)

22 views
Skip to first unread message

Daniel G. Gamonal

unread,
Apr 29, 2020, 12:30:18 PM4/29/20
to Marvin Project
For the sake of image comparison (I want to tell if two images are the same) I came across this post on Stack Overflow (https://stackoverflow.com/questions/22411041/compare-images-with-marvinframework#22426261)
At first it wasn't working so I followed the tutorial present on (http://marvinproject.sourceforge.net/en/tutorials/02_firstApplication/firstApplication.html) step by step, and it works nice.
Then I just added the code I want to test, and it's failing all the same.

Added code

else if(e.getSource() == buttonDiff){
            MarvinAttributes attrOut = new MarvinAttributes();
            imagePlugin = MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.difference.differenceColor");
            MarvinImage image2 = MarvinImageIO.loadImage("./ref/2C.jpg");
            MarvinImageIO.saveImage(image2, "./out/c.jpg");
            imagePlugin.process(image, image2, attrOut);
        }

Stack trace:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.marvinproject.image.difference.differenceColor.DifferenceColor.process(DifferenceColor.java:67)
    at marvin.plugin.MarvinAbstractImagePlugin.process(MarvinAbstractImagePlugin.java:65)
    at org.xxxxx.marvin.fistApp.FirstApplication.actionPerformed(FirstApplication.java:102)

DifferenceColor.java @ 67 says: l_redB = imageB.getIntComponent0(x, y); So seems imageB is null in the scope, but you can ensure it's not at invocation time, notice "MarvinImageIO.saveImage(image2, "./out/c.jpg");", it works ok.

Can this be a bug introduced by a later version?

Regards.
Reply all
Reply to author
Forward
0 new messages