[ITK Community] [Insight-users] Compressing Tif files

Fethallah Benmansour fethallah at gmail.com
Mon Dec 23 04:30:43 EST 2013


Hi Bill,

I hope you had a great weekend.
I followed the modification you suggested (and rebuild ITK of course).
Unfortunately, the output images are still uncompressed.

In addition, close to the line you mentioned, I can see:

TIFFSetField(tif, TIFFTAG_JPEGQUALITY, 75); // Parameter

Could you please add that as a parameter of itkTIFFImageIO in you gerrit
patch ?

Kind regards,

--
Fethallah



On Fri, Dec 20, 2013 at 5:52 PM, Bill Lorensen <bill.lorensen at gmail.com>wrote:

> I found the first problem. I will submit a gerrit patch when I resolve the
> other issues and make a test.
>
> Try this. In itkTIFFImageIO.cxx delete  line 1847 which contains:
>       photometric = PHOTOMETRIC_YCBCR;
>
> Let me know if your data compresses.
>
>
> On Fri, Dec 20, 2013 at 11:24 AM, Bill Lorensen <bill.lorensen at gmail.com>wrote:
>
>> Ok, I can reproduce the error with my sample code. I have to add
>> writer->UseCompressionOn().
>>
>> I think that also points out an error…
>>
>> Now I can debug.
>>
>>
>> On Fri, Dec 20, 2013 at 11:17 AM, Fethallah Benmansour <
>> fethallah at gmail.com> wrote:
>>
>>> Hi Bill,
>>>
>>> Thanks again.
>>> Your code works indeed, however the output image is not JPEG compressed
>>> as it should be:
>>>
>>> [image: Inline image 1]
>>>
>>>
>>> Thanks for your help.
>>>
>>> --
>>> Fethallah
>>>
>>> --
>>> Fethallah
>>>
>>>
>>> On Fri, Dec 20, 2013 at 5:06 PM, Bill Lorensen <bill.lorensen at gmail.com>wrote:
>>>
>>>> Can you try this program:
>>>>
>>>> On Fri, Dec 20, 2013 at 11:03 AM, Fethallah Benmansour
>>>> <fethallah at gmail.com> wrote:
>>>> > 4.4.2
>>>> > Let me know if you need more info, I can also send you my cxx and my
>>>> > CMakelists.txt
>>>> >
>>>> > Thanks,
>>>> >
>>>> > --
>>>> > Fethallah
>>>> >
>>>> > --
>>>> > Fethallah
>>>> >
>>>> >
>>>> > On Fri, Dec 20, 2013 at 4:59 PM, Bill Lorensen <
>>>> bill.lorensen at gmail.com>
>>>> > wrote:
>>>> >>
>>>> >> What version of ITK are you using?
>>>> >>
>>>> >>
>>>> >> On Fri, Dec 20, 2013 at 10:56 AM, Fethallah Benmansour
>>>> >> <fethallah at gmail.com> wrote:
>>>> >> > Thanks Bill for your prompt reply.
>>>> >> > I'm looking forward to hearing from you.
>>>> >> >
>>>> >> > --
>>>> >> > Fethallah
>>>> >> >
>>>> >> > --
>>>> >> > Fethallah
>>>> >> >
>>>> >> >
>>>> >> > On Fri, Dec 20, 2013 at 4:50 PM, Bill Lorensen <
>>>> bill.lorensen at gmail.com>
>>>> >> > wrote:
>>>> >> >>
>>>> >> >> I do not see any tests that use tiff compression. You may have
>>>> founds
>>>> >> >> a bug. I'll investigate.
>>>> >> >>
>>>> >> >>
>>>> >> >> On Fri, Dec 20, 2013 at 10:35 AM, Fethallah <fethallah at gmail.com>
>>>> >> >> wrote:
>>>> >> >> > Hi there,
>>>> >> >> >
>>>> >> >> > I would like to compress some relatively large tif files.
>>>> >> >> >
>>>> >> >> > My code looks like:
>>>> >> >> > =================
>>>> >> >> > ReaderType::Pointer reader = ReaderType::New();
>>>> >> >> > reader->SetFileName( argv[1] );
>>>> >> >> > reader->Update();
>>>> >> >> >
>>>> >> >> > WriterType::Pointer writer = WriterType::New();
>>>> >> >> > writer->SetInput( reader->GetOutput() );
>>>> >> >> > writer->SetFileName( argv[2] );
>>>> >> >> > writer->SetUseCompression(true);
>>>> >> >> > typedef  itk::TIFFImageIO TIFFIOType;
>>>> >> >> > TIFFIOType::Pointer tiffIO = TIFFIOType::New();
>>>> >> >> > tiffIO->SetCompressionToJPEG();
>>>> >> >> > writer->SetImageIO(tiffIO);
>>>> >> >> > writer->Update();
>>>> >> >> > =================
>>>> >> >> > when I run
>>>> >> >> > binary.exe Image.tif ImageCompressed.tif
>>>> >> >> >
>>>> >> >> > I'm getting the following exception:
>>>> >> >> > JPEGLib: Bogus input colorspace.
>>>> >> >> > itk::ExceptionObject (000000000012F6E8)
>>>> >> >> > Location: "unknown"
>>>> >> >> > File:
>>>> >> >> >
>>>> >> >> >
>>>> >> >> >
>>>> ..\..\..\..\..\src\InsightToolkit-4.4.2\Modules\IO\TIFF\src\itkTIFFImageIO.cxx
>>>> >> >> > Line: 1946
>>>> >> >> > Description: itk::ERROR: TIFFImageIO(00000000020D4420):
>>>> TIFFImageIO:
>>>> >> >> > error
>>>> >> >> > out of disk space
>>>> >> >> >
>>>> >> >> >
>>>> >> >> > The pixel type of the input images is UCHAR.
>>>> >> >> >
>>>> >> >> > An other question regarding JPG compression in TIF files,
>>>> assuming
>>>> >> >> > this
>>>> >> >> > works with ITK.
>>>> >> >> > Is there a way to control the compression rate ?
>>>> >> >> >
>>>> >> >> > Thanks into advance for your help.
>>>> >> >> >
>>>> >> >> >
>>>> >> >> > --
>>>> >> >> > Fethallah
>>>> >> >> >
>>>> >> >> >
>>>> >> >> >
>>>> >> >> >
>>>> >> >> > --
>>>> >> >> > View this message in context:
>>>> >> >> >
>>>> >> >> >
>>>> http://itk-insight-users.2283740.n2.nabble.com/Compressing-Tif-files-tp7584685.html
>>>> >> >> > Sent from the ITK Insight Users mailing list archive at
>>>> Nabble.com.
>>>> >> >> > _____________________________________
>>>> >> >> > Powered by www.kitware.com
>>>> >> >> >
>>>> >> >> > Visit other Kitware open-source projects at
>>>> >> >> > http://www.kitware.com/opensource/opensource.html
>>>> >> >> >
>>>> >> >> > Kitware offers ITK Training Courses, for more information visit:
>>>> >> >> > http://www.kitware.com/products/protraining.php
>>>> >> >> >
>>>> >> >> > Please keep messages on-topic and check the ITK FAQ at:
>>>> >> >> > http://www.itk.org/Wiki/ITK_FAQ
>>>> >> >> >
>>>> >> >> > Follow this link to subscribe/unsubscribe:
>>>> >> >> > http://www.itk.org/mailman/listinfo/insight-users
>>>> >> >>
>>>> >> >>
>>>> >> >>
>>>> >> >> --
>>>> >> >> Unpaid intern in BillsBasement at noware dot com
>>>> >> >
>>>> >> >
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Unpaid intern in BillsBasement at noware dot com
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Unpaid intern in BillsBasement at noware dot com
>>>>
>>>
>>>
>>
>>
>> --
>> Unpaid intern in BillsBasement at noware dot com
>>
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20131223/9723754e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TiffCompressionIssue.JPG
Type: image/jpeg
Size: 68232 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/community/attachments/20131223/9723754e/attachment.jpe>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


More information about the Community mailing list