You are here

Image Recongination


i am creating application where user loads image do some training on it that add some noise over that image after user can recall the original image. i have seen image example given by seema and i am following the same example but hen i tried to run my program it is giving me nullpointerexception.

here is my code :

// for creating image on jpanel

public void setImage(File imageFile) throws IOException {
this.imageFile = imageFile;
image = getToolkit().getImage("Image Files//" + imageFile.getName());


public void createNetwork() throws IOException{
downsampleWidth = 16;
downsampleHeight = 16;
downsample = new RGBDownsample();
training = new ImageMLDataSet(downsample, false, 1, -1);
System.out.println("traning is created");

//for process network()

public void processNetwork() throws IOException{
System.out.println("Downsampling images...");
final MLData ideal = new BasicMLData(0);
final Image img =;
final ImageMLData data = new ImageMLData(img);, ideal);, this.downsampleWidth); = EncogUtility.simpleFeedForward(, 100, 0,, true);
System.out.println("Created network: " +;

public void processTrain() throws IOException {
String strMode = "x";
System.out.println("Training Beginning... Output patterns = " + 0);
final ResilientPropagation train = new ResilientPropagation(,;
train.addStrategy(new ResetStrategy(0.25, 50 ));
if (strMode.equalsIgnoreCase("gui")) {
} else {
EncogUtility.trainConsole(train,,, 1);
System.out.println("Training Stopped...");

here is printstacktrace:

traning is created
Downsampling images...
Created network: [BasicNetwork: Layers=3]
Added input image:1001_941581367_375330851_H080042_L.jpg
Training Beginning... Output patterns = 0
Beginning training...
Exception in thread "AWT-EventQueue-0" org.encog.EncogError: java.lang.NullPointerException
at org.encog.util.simple.EncogUtility.trainConsole(
at org.beproject.neuralnetwork.input.IOImage.processTrain(
at org.beproject.neuralnetwork.ui.ApplicationGraphicalInterface$17.actionPerformed(
at javax.swing.AbstractButton.fireActionPerformed(
at javax.swing.AbstractButton$Handler.actionPerformed(
at javax.swing.DefaultButtonModel.fireActionPerformed(
at javax.swing.DefaultButtonModel.setPressed(
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(
at java.awt.Component.processMouseEvent(
at javax.swing.JComponent.processMouseEvent(
at java.awt.Component.processEvent(
at java.awt.Container.processEvent(
at java.awt.Component.dispatchEventImpl(
at java.awt.Container.dispatchEventImpl(
at java.awt.Component.dispatchEvent(
at java.awt.LightweightDispatcher.retargetMouseEvent(
at java.awt.LightweightDispatcher.processMouseEvent(
at java.awt.LightweightDispatcher.dispatchEvent(
at java.awt.Container.dispatchEventImpl(
at java.awt.Window.dispatchEventImpl(
at java.awt.Component.dispatchEvent(
at java.awt.EventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForFilters(
at java.awt.EventDispatchThread.pumpEventsForFilter(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(
Caused by: java.lang.NullPointerException
at org.encog.mathutil.error.ErrorCalculation.updateError(
... 29 more

i am using exactly same code with by requirement. please help out


Neural Network Forums: 

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer