Save all pixel values as one matrix

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Save all pixel values as one matrix


I am trying to save all the pixel values as on matrix in the image that I have imported from my previous coding. To do so, I have read online that would have to write the following:

                ImagePlus image = new ImagePlus (path);
               //ImagePlus image = IJ.getImage();
                       width = image.getWidth();
                       height = image.getHeight();
                       ImageProcessor imp = image.getProcessor();
                       short[] pix = (short[])imp.getPixels();

In this case I am not sure whether to use getImage() or new ImagePlus("filename") as I have managed to get the path of my image. Also, having written this code, I cant output/save the pixels as an array.

Can someone lend me hand and tell me how to go further?

Many Thanks,