Converting to GraySCale

Hello!

I am trying to convert an RGB ImagePlus to grayscale but when I attempt to call getPixels on the image processor of the converted image, the program hangs at that point. What could be the cause of that? See the sniped below:

Hopefully someone will be able to help you, but you may need to provide more context than a few lines of code, or something about the size/shape of what you are passing through the script.

1 Like

After using

ic.convertToGray8()

the image type is no longer RGB and the pixel type is no longer int.
The image type is 8bit and the pixel type is byte.
Use

byte pixels[] = (byte[]) copy. getProcessor().getPixels();
2 Likes