简体   繁体   中英

converting an image format with ImageJ

I have the following code that I use to convert an image from fits format to jpeg format

  ImagePlus fitsImage = openImage(fitsImagePath);
  final File out = new File(fullPath +  fileNameNoExt + ".jpg");           
  BufferedImage jpgImage = fitsImage.getBufferedImage();           
  ImageIO.write(jpgImage, "jpg", out);       

the actual format change is working and I do get a jpg file, but the problem is that the resulting file is in black and white and I know for a fact that the image I am using is colored.

So the question is what should I do to make the resulting image colored.

cheers,

es

For some reason the getBufferedImage() function is only copying the data in an 8-bit format. As I am unfamiliar with fits format, what pixel depth does it have and what pixel depth does your data have?

If you are importing in 8-bit which is false colored with red, green, or blue, then when you export it will maintain its 8-bit grey scale and not the false color.

If you want it to maintain its rgb, you will have to convert it into a rgb format before exporting.

The function command flatten might help as it will convert the picture to an RGB format

 fitsImage.flatten()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM