Converting (and saving) to single channel grayscale JPG

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

Converting (and saving) to single channel grayscale JPG

Andy-92
I need to convert images to single channel grayscale images (such as when
you use imageMagick to do: convert blah.jpg -colorspace grayscale
blahgray.jpg

I have tried the following:
ImageConverter ic = new ImageConverter(img);
ic.convertToGray8();
FileSaver fs = new FileSaver(img);
fs.saveAsJpeg("Blah.jpg");


but if I try to use it in matlab, matlab complains that it is not a single
channel grayscale image.

Any help is greatly appreciated!
--Andrew
Reply | Threaded
Open this post in threaded view
|

Re: Converting (and saving) to single channel grayscale JPG

Michael Schmid
Hi Andrew,

ImageJ saves also grayscale images as color JPEG - you see this
also when opening such an image in ImageJ. I guess that the
difference in file size between a "true" grayscale JPEG and a
color JPEG with grayscale data is negligible.

My suggestion is using TIFF format - it also avoids artifacts
caused by the lossy JPEG compression.

Michael
________________________________________________________________

On 30 Jun 2008, at 19:01, Andy wrote:

> I need to convert images to single channel grayscale images (such  
> as when
> you use imageMagick to do: convert blah.jpg -colorspace grayscale
> blahgray.jpg
>
> I have tried the following:
> ImageConverter ic = new ImageConverter(img);
> ic.convertToGray8();
> FileSaver fs = new FileSaver(img);
> fs.saveAsJpeg("Blah.jpg");
>
>
> but if I try to use it in matlab, matlab complains that it is not a  
> single
> channel grayscale image.
>
> Any help is greatly appreciated!
> --Andrew