You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Juergen Stumpe <js...@gmail.com> on 2018/06/05 09:14:58 UTC
Writing 16 Bits Per Sample To Tiff File
Hello,
I need to write grayscale pixels with 16 bits per sample into a Tiff file.
In the provided Apache examples the Imaging.writeImage() method is
used to write image data into a file. But the image data source has
always to be a BufferedImage, however BufferedImage handles only 8
bits per sample, not 16 bits.
Is there an alternative class/method to write image data to a Tiff
file, supporting 16 bits per sample? Or how can it be done with
BufferedImage?
Thanks
Juergen
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: Writing 16 Bits Per Sample To Tiff File
Posted by Juergen Stumpe <js...@gmail.com>.
Thanks Damjan,
For the hint. I'll try it.
Juergen
On Tue, Jun 5, 2018 at 12:04 PM, Damjan Jovanovic <da...@apache.org> wrote:
> You can make a BufferedImage with TYPE_USHORT_GRAY for 16 bits per sample.
>
> Damjan
>
>
>
> On Tue, Jun 5, 2018 at 11:15 AM Juergen Stumpe <js...@gmail.com> wrote:
>
>> Hello,
>>
>> I need to write grayscale pixels with 16 bits per sample into a Tiff file.
>>
>> In the provided Apache examples the Imaging.writeImage() method is
>> used to write image data into a file. But the image data source has
>> always to be a BufferedImage, however BufferedImage handles only 8
>> bits per sample, not 16 bits.
>>
>> Is there an alternative class/method to write image data to a Tiff
>> file, supporting 16 bits per sample? Or how can it be done with
>> BufferedImage?
>>
>> Thanks
>>
>> Juergen
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: Writing 16 Bits Per Sample To Tiff File
Posted by Juergen Stumpe <js...@gmail.com>.
Hi,
I tried it with BufferedImage TYPE_USHORT_GRAY, and I think from the
BufferedImage point of view it seems to be OK.
raster = ShortInterleavedRaster
dataBuffer = DataBufferShort
imageType = 11
I'm just not sure about the colorModel = ComponentColorModel?
I write this BufferedImage to disc with the following code:
File targetFile = new File(targetTIFF);
ImageFormat format = ImageFormats.TIFF;
Map<String, Object> params = new HashMap<>();
try {
Imaging.writeImage(bufferedImage, targetFile, format, params);
} catch (ImageWriteException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But when I read the file that's been written with the code above, it has
BitsPerSample: 8, 8, 8 (3 short) instead of BitsPerSample: 16 (1 short).
What needs to be changed to get 16 BitsPerSample in one short written?
Is something wrong with the BufferedImage, or must be additional
parameters set for Imaging.writeImage(bufferedImage, targetFile,
format, params)?
Thanks
Juergen
On Tue, Jun 5, 2018 at 12:04 PM Damjan Jovanovic <da...@apache.org> wrote:
>
> You can make a BufferedImage with TYPE_USHORT_GRAY for 16 bits per sample.
>
> Damjan
>
>
>
> On Tue, Jun 5, 2018 at 11:15 AM Juergen Stumpe <js...@gmail.com> wrote:
>
> > Hello,
> >
> > I need to write grayscale pixels with 16 bits per sample into a Tiff file.
> >
> > In the provided Apache examples the Imaging.writeImage() method is
> > used to write image data into a file. But the image data source has
> > always to be a BufferedImage, however BufferedImage handles only 8
> > bits per sample, not 16 bits.
> >
> > Is there an alternative class/method to write image data to a Tiff
> > file, supporting 16 bits per sample? Or how can it be done with
> > BufferedImage?
> >
> > Thanks
> >
> > Juergen
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: Writing 16 Bits Per Sample To Tiff File
Posted by Damjan Jovanovic <da...@apache.org>.
You can make a BufferedImage with TYPE_USHORT_GRAY for 16 bits per sample.
Damjan
On Tue, Jun 5, 2018 at 11:15 AM Juergen Stumpe <js...@gmail.com> wrote:
> Hello,
>
> I need to write grayscale pixels with 16 bits per sample into a Tiff file.
>
> In the provided Apache examples the Imaging.writeImage() method is
> used to write image data into a file. But the image data source has
> always to be a BufferedImage, however BufferedImage handles only 8
> bits per sample, not 16 bits.
>
> Is there an alternative class/method to write image data to a Tiff
> file, supporting 16 bits per sample? Or how can it be done with
> BufferedImage?
>
> Thanks
>
> Juergen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>