reg. imageJ

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

reg. imageJ

dr.cs1973
I am working with Matlab for several years. I am new to imageJ, find it difficult. So, I am in need of your help experts.

How to read an image using imageJ and process the values then write to a new file?

Confused with macros, plugins, etc.

Thanks in advance,

Saravanan

Reply | Threaded
Open this post in threaded view
|

Re: reg. imageJ

dr.cs1973
I have tried plugin,

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class My_Plugin implements PlugIn {

        public void run(String arg) {

        ImagePlus imp=new ImagePlus("e:\\kamalesh.jpg");

        imp.show();

        int w = imp.getWidth(), h = imp.getHeight();

        byte[] pix = (byte[]) imp.getPixels();
        }

}

which is not working, creating following error.

C:\Program Files\ImageJ\plugins\Examples\My_Plugin.java:18: cannot find symbol
symbol  : method getPixels()
location: class ij.ImagePlus
        byte[] pix = (byte[]) imp.getPixels();
                                 ^
1 error

Please help me to solve this error.
Reply | Threaded
Open this post in threaded view
|

Re: reg. imageJ

dr.cs1973
I have modified the code and got a different error. Its working fine upto width and height. The error is only in the data[1][i][j]

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class My_Plugin implements PlugIn {

        public void run(String arg) {

        ImagePlus imp=IJ.openImage("e:\\kamalesh.jpg");

        ImageProcessor ip = imp.getProcessor();

        int[] data = (int[])ip.getPixels();

// imp.show();

        int w = imp.getWidth(), h = imp.getHeight();

        IJ.log("Width " + w);
        IJ.log("Height " + h);

        for (int i=0;i<5;i++)
                for(int j=0;j<5;j++)
                        IJ.log("Data " + data[0][i][j]);

        }

}


C:\Program Files\ImageJ\plugins\Examples\My_Plugin.java:27: array required, but int found
                        IJ.log("Data " + data[1][i][j]);
                                                ^
1 error

Pls. help me.