How to pass an array from a plugin to a macro?

Posted by Emmanuel Levy on
URL: http://imagej.273.s1.nabble.com/How-to-pass-an-array-from-a-plugin-to-a-macro-tp5002492.html

Hello,

I wrote a simple plugin that puts all pixel values of a selected ROI
into a 1D table. What I can't figure out is how to pass the resulting
1D array to a macro calling the plugin? i.e., similarly to
getStatistics, which makes a histogram array available in the macro
calling the function for example.

Many thanks for your help,

All the best,

Emmanuel

~~~~~~~~~~~~~
Run function of the (very simple) plugin:

   In the end, the float array myT contains the pixel values of the
currently selected ROI --> how to make myT available in a macro?

        public float[] myT;

        public void run(ImageProcessor ip) {

       
                Rectangle r = ip.getRoi();
                ImageProcessor mask = ip.getMask();
                if (mask==null) {
                mask = new ByteProcessor(r.width, r.height);
                mask.invert();
            }
           
                int total = 0;
                for (int x= 0; x < r.width; x++) {
                        for (int y=0; y < r.height; y++) {
                                if(mask.getf(x,y) >  0){
                                        total++;
                                }
                        }
                }

                myT = new float[total];
                total=0;
                for (int x= 0; x < r.width; x++) {
                        for (int y=0; y < r.height; y++) {
                                if(mask.getf(x,y) >  0){
                                        myT[total++]=ip.getf(x, y);
                                }
                                //IJ.log("Pixel: Y="+y+" ; X="+x+" ; value=" + ip.getf(x, y) +
"Mask = "+ mask.getf(x,y) );
                        }
                }
        }

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html