Click to See Complete Forum and Search --> : Cannot run


merxais
03-11-2007, 10:56 PM
I found 12 errors running this ... anyone can help please?:confused:


/*
* Created on Jun 30, 2005
* @author Rafael Santos (rafael.santos@lac.inpe.br)
*
* Part of the Java Advanced Imaging Stuff site
* (http://www.lac.inpe.br/~rafael.santos/Java/JAI)
*
* STATUS: Complete.
*
* Redistribution and usage conditions must be done under the
* Creative Commons license:
* English: http://creativecommons.org/licenses/by-nc-sa/2.0/br/deed.en
* Portuguese: http://creativecommons.org/licenses/by-nc-sa/2.0/br/deed.pt
* More information on design and applications are on the projects' page
* (http://www.lac.inpe.br/~rafael.santos/Java/JAI).
*/
package algorithms.segmentation.regiongrowing;

import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import display.DisplayDEM;
import display.DisplayTwoSynchronizedImages;

/**
* This class demonstrates the SimpleRegionGrowing class with an user interface.
*/
public class DemoSimpleRegionGrowing
{
/**
* The application entry point. We will need to give a file name of an image to be
* segmented.
* @param args the command-line arguments.
*/
public static void main(String[] args)
{
// We need the image filename. Additional arguments will force image preprocessing.
if (args.length == 0)
{
System.err.println("Usage: java algorithms.segmentation.regiongrowing.DemoSimpleRegionGrowing image [preprocess]");
System.exit(0);
}
// Read the image.
PlanarImage image = JAI.create("fileload", args[0]);
// Create the image processing task.
SimpleRegionGrowing task = new SimpleRegionGrowing(image,(args.length > 1));
// Create a display for the original and binarized image.
DisplayTwoSynchronizedImages d =
new DisplayTwoSynchronizedImages(image,task.getInternalImage());
// Display the original and binarized images in a JFrame.
JFrame origFrame = new JFrame();
origFrame.setTitle("Original Image and Binarized Image");
origFrame.getContentPane().add(new JScrollPane(d));
// Set the closing operation so the application is finished.
origFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
origFrame.pack(); // adjust the frame size using preferred dimensions.
origFrame.setVisible(true); // show the frame.
// Create a ProgressBar in a JFrame.
JProgressBar progressBar = new JProgressBar(0,(int)task.getSize());
progressBar.setValue(0);
progressBar.setStringPainted(true);
JFrame progressFrame = new JFrame();
progressFrame.setTitle("Progress");
progressFrame.getContentPane().add(progressBar);
// Set the closing operation so the application is finished.
progressFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
progressFrame.pack(); // adjust the frame size using preferred dimensions.
progressFrame.setVisible(true); // show the frame.
// We're ready to go.
task.start();
// Change the progress bar while the segmentation is being performed.
while(!task.isFinished())
{
progressBar.setValue((int)task.getPosition());
progressBar.repaint();
}
// Segmentation has finished.
progressBar.setValue((int)task.getPosition());
// Create a new frame to show the results.
JFrame resultsFrame = new JFrame();
resultsFrame.setTitle("Segmentation results");
// Add to the JFrame's ContentPane an instance of DisplayDEM with the processed image.
resultsFrame.getContentPane().add(new JScrollPane(new DisplayDEM(task.getOutput())));
// Set the closing operation so the application is finished.
resultsFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
resultsFrame.pack(); // adjust the frame size using preferred dimensions.
resultsFrame.setVisible(true); // show the frame.
// Let's see some textual data about the segmentation.
System.out.println("Number of regions: "+task.getNumberOfRegions());
for(int c=1;c<=task.getNumberOfRegions();c++)
System.out.println("Region "+c+": "+task.getPixelCount(c)+" pixels");
}

}

agent_x91
03-12-2007, 04:57 AM
It'd be a great deal easier to find errors if given the error messages. Could you copy and paste the errors?

merxais
03-12-2007, 10:31 AM
It'd be a great deal easier to find errors if given the error messages. Could you copy and paste the errors?


seg.java:30: class DemoSimpleRegionGrowing is public, should be declared in a fi
le named DemoSimpleRegionGrowing.java
public class DemoSimpleRegionGrowing
^
seg.java:19: package javax.media.jai does not exist
import javax.media.jai.JAI;
^
seg.java:20: package javax.media.jai does not exist
import javax.media.jai.PlanarImage;
^
seg.java:24: package display does not exist
import display.DisplayDEM;
^
seg.java:25: package display does not exist
import display.DisplayTwoSynchronizedImages;
^
seg.java:46: cannot resolve symbol
symbol : class PlanarImage
location: class algorithms.segmentation.regiongrowing.DemoSimpleRegionGrowing
PlanarImage image = JAI.create("fileload", args[0]);
^
seg.java:46: cannot resolve symbol
symbol : variable JAI
location: class algorithms.segmentation.regiongrowing.DemoSimpleRegionGrowing
PlanarImage image = JAI.create("fileload", args[0]);
^
seg.java:48: cannot resolve symbol
symbol : class SimpleRegionGrowing
location: class algorithms.segmentation.regiongrowing.DemoSimpleRegionGrowing
SimpleRegionGrowing task = new SimpleRegionGrowing(image,(args.length > 1));

^
seg.java:48: cannot resolve symbol
symbol : class SimpleRegionGrowing
location: class algorithms.segmentation.regiongrowing.DemoSimpleRegionGrowing
SimpleRegionGrowing task = new SimpleRegionGrowing(image,(args.length > 1));

^
seg.java:50: cannot resolve symbol
symbol : class DisplayTwoSynchronizedImages
location: class algorithms.segmentation.regiongrowing.DemoSimpleRegionGrowing
DisplayTwoSynchronizedImages d = new DisplayTwoSynchronizedImages(image,task
.getInternalImage());
^
seg.java:50: cannot resolve symbol
symbol : class DisplayTwoSynchronizedImages
location: class algorithms.segmentation.regiongrowing.DemoSimpleRegionGrowing
DisplayTwoSynchronizedImages d = new DisplayTwoSynchronizedImages(image,task
.getInternalImage());
^
seg.java:84: cannot resolve symbol
symbol : class DisplayDEM
location: class algorithms.segmentation.regiongrowing.DemoSimpleRegionGrowing
resultsFrame.getContentPane().add(new JScrollPane(new DisplayDEM(task.getOut
put())));
^
12 errors

merxais
03-12-2007, 01:53 PM
anyone please help :(

TheBearMay
03-13-2007, 11:20 AM
Well looking at the API ( http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/index.html ) I don't see a javax.media.jai.JAI just javax.media.jai so unless you've created it....

javax.media.jai
javax.media.jai.iterator
javax.media.jai.operator
javax.media.jai.registry
javax.media.jai.remote
javax.media.jai.tilecodec
javax.media.jai.util
javax.media.jai.widget

agent_x91
03-14-2007, 07:00 AM
Never mind I just read the last post; you've just given incorrect package names. Change them to what [insert name here] suggested and it should compile fine unless you've made other errors.