<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>

<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p
        {mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=FR link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Bill,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>I tested it and it works
perfectly now, so you can close the bug issue.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Thanks a lot!<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Sebastien<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span lang=EN-US style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span lang=EN-US
style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>From:</span></font></b><font
size=2 face=Tahoma><span lang=EN-US style='font-size:10.0pt;font-family:Tahoma'>
Bill Lorensen [mailto:bill.lorensen@gmail.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> vendredi 14 décembre 2007
14:36<br>
<b><span style='font-weight:bold'>To:</span></b> Sébastien Fricker<br>
<b><span style='font-weight:bold'>Cc:</span></b> Xabier Artaechevarria Artieda;
insight-users@itk.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [Insight-users]
Overwriting TIFF files</span></font><span lang=EN-US><o:p></o:p></span></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Sebastien,<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Please update and try&nbsp;one more time. I had forgotten to remove the
dummy TIFFClose that was in TIFFImageIO.cxx. I'm not sure why my test worked.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Bill<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>On Dec 14, 2007 4:06 AM, Sébastien Fricker &lt;<a
href="mailto:sebastien.fricker@phaseview.net">sebastien.fricker@phaseview.net</a>&gt;
wrote:<o:p></o:p></span></font></p>

<div vlink=blue link=blue>

<div>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>Bill,</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>I updated itkTIFFImageIO.cxx and tested it. Now I
get an error message when the tiff file cannot be written, which is good. </span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>The other problem is still present though: I
can't modify the file in-place because after calling
inputImageReader-&gt;Update() the file remains open. </span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>To me it looks like TIFFClose</span></font><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:
"Courier New"'> </span></font><font size=2 color=navy face=Arial><span
lang=EN-GB style='font-size:10.0pt;font-family:Arial;color:navy'>does not do
what it's supposed to do (i.e. close the file&#8230;).</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>After TIFFClose is being called during
inputImageReader-&gt;Update(), if I try to open the file with another
application such as Microsoft Document Imaging, it says the file is already in
use by another application, meaning ITK did not unlock it. </span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>But maybe I'm doing something wrong&#8230;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>Could you please check it out?</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>Thanks a lot.</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;
font-family:Arial;color:navy'>Sebastien</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:
Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<p><font size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:
Arial;color:navy'>&nbsp;</span></font><o:p></o:p></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span lang=EN-US style='font-size:12.0pt'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p><b><font size=2 face=Tahoma><span lang=EN-US style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span lang=EN-US style='font-size:10.0pt;font-family:Tahoma'> Bill
Lorensen [mailto:<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>]
<br>
<b><span style='font-weight:bold'>Sent:</span></b> jeudi 13 décembre 2007 21:13<br>
<b><span style='font-weight:bold'>To:</span></b> Sébastien Fricker<br>
<b><span style='font-weight:bold'>Cc:</span></b> Xabier Artaechevarria Artieda;
<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>
<o:p></o:p></span></font></p>

<div>

<div>

<p class=MsoNormal><font size=2 face=Tahoma><span lang=EN-US style='font-size:
10.0pt;font-family:Tahoma'><br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [Insight-users]
Overwriting TIFF files<o:p></o:p></span></font></p>

</div>

</div>

</div>

<div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Sebastien,<o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Thanks
for submitting the bug report. It was pretty easy to fix.<o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'><a
href="http://public.kitware.com/Bug/view.php?id=6159" target="_blank">http://public.kitware.com/Bug/view.php?id=6159</a><o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Please
update itkTIFFImageIO.cxx and see if it fixes your problem. If it does, I'll
close the bug.<o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Bill<o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'><br>
<br>
&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>On Dec
13, 2007 1:17 PM, Bill Lorensen &lt;<a href="mailto:bill.lorensen@gmail.com"
target="_blank">bill.lorensen@gmail.com</a>&gt; wrote: <o:p></o:p></span></font></p>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Sebastien,<br>
<br>
This looks like a bug to me. I can't see itkTIFFImageIO closing the file. Also,
the write should not silently fail. <br>
Please enter a bug report: <br>
<a href="http://public.kitware.com/Bug/my_view_page.php" target="_blank">http://public.kitware.com/Bug/my_view_page.php</a><br>
<font color="#888888"><span style='color:#888888'><br>
Bill</span></font> <o:p></o:p></span></font></p>

<div>

<div>

<p style='margin-bottom:12.0pt'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>On Dec
13, 2007 12:56 PM, Sébastien Fricker &lt;<a
href="mailto:sebastien.fricker@phaseview.net" target="_blank">sebastien.fricker@phaseview.net
</a>&gt; wrote:<o:p></o:p></span></font></p>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Thank you
Xabi,<br>
I have already tested writing to a different name and it works just fine. <br>
Only when input name == output name do I get a problem: the original file is <br>
not modified.<br>
<br>
The part of the code that fails is in Itktiffimageio.cxx, in the<br>
TIFFImageIO::InternalWrite function.<br>
The problem appears at the following piece of code: <br>
<br>
&nbsp;TIFF *tif = TIFFOpen(m_FileName.c_str(), &quot;w&quot;); <br>
&nbsp;if ( !tif )<br>
&nbsp; &nbsp;{<br>
&nbsp; &nbsp;itkDebugMacro( &lt;&lt; &quot;Returning&quot; );<br>
&nbsp; &nbsp;return;<br>
&nbsp; &nbsp;}<br>
<br>
In my case !tif == true because the image was already open at the beginning <br>
of the pipeline.<br>
<br>
Surprisingly it works with BMP images though. Does this mean TIFF files <br>
cannot be modified in-place?<br>
<br>
Sebastien<o:p></o:p></span></font></p>

<div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'><br>
-----Original Message-----<br>
From: insight-users-bounces+sebastien.fricker=<a
href="mailto:phaseview.net@itk.org" target="_blank">phaseview.net@itk.org </a><br>
[mailto:<a
href="mailto:insight-users-bounces+sebastien.fricker=phaseview.net@itk.org"
target="_blank"> insight-users-bounces+sebastien.fricker=phaseview.net@itk.org </a>]
On<br>
Behalf Of Xabier Artaechevarria Artieda <br>
Sent: jeudi 13 décembre 2007 18:21<br>
To: <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org
</a><br>
Subject: Re: [Insight-users] Overwriting TIFF files<br>
<br>
Hi Sébastien,<br>
I think I have done this, sometimes without even realising :( <br>
Try writing with a different name to see if that is the &nbsp;problem.<br>
Good luck, <br>
Xabi<br>
<br>
--<br>
Xabier Artaechevarria<br>
Cancer Imaging Laboratory <br>
Centre for Applied Medical Research<br>
<a href="http://www.cima.es/" target="_blank">www.cima.es</a><br>
<br>
<br>
<br>
Sébastien Fricker &lt;<a href="mailto:sebastien.fricker@phaseview.net"
target="_blank"> sebastien.fricker@phaseview.net </a>&gt; ha escrito:<br>
<br>
&gt; Dear ITK users,<br>
&gt;<br>
&gt; I wrote a program that opens an image, transforms it via the Resample <br>
image<br>
&gt; filter and writes the result to the original image file (see code fragment
<br>
&gt; below).<br>
&gt;<br>
&gt; This works fine when I use BMP images.<br>
&gt;<br>
&gt; It does not work when I use TIF images: the original image is not <br>
modified.<br>
&gt; What happens is that the writer at the end does not do anything: <br>
apparently<br>
&gt; it cannot open the image for writing, probably because the same image was<br>
&gt; open for reading at the beginning of the pipeline. <br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Is this a bug or am I doing something wrong? <br>
&gt;<br>
&gt; How can I modify a TIF file in-place?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Thanks for any hint.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Sebastien <br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; CODE FRAGMENT:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --------------------------------------------------------<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; //DEFINE IMAGE TYPES<br>
&gt;<br>
&gt; const unsigned int Dimension = 2; <br>
&gt;<br>
&gt; typedef unsigned short PixelType;<br>
&gt; <br>
&gt; typedef double InternalPixelType;<br>
&gt;<br>
&gt; typedef itk::Image&lt; PixelType, Dimension &gt; ImageType;<br>
&gt;<br>
&gt; typedef itk::Image&lt; InternalPixelType, Dimension &gt;
InternalImageType; <br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; //READ INPUT IMAGE<br>
&gt;<br>
&gt; typedef itk::ImageFileReader&lt; ImageType &nbsp;&gt; ImageReaderType;<br>
&gt;<br>
&gt; ImageReaderType::Pointer &nbsp;inputImageReader &nbsp;=
ImageReaderType::New();<br>
&gt;<br>
&gt; <br>
&gt;<br>
&gt; inputImageReader-&gt;SetFileName( fileName );<br>
&gt;<br>
&gt; inputImageReader-&gt;Update();<br>
&gt;<br>
&gt; ImageType::Pointer inputImage = inputImageReader-&gt;GetOutput();<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; <br>
&gt;<br>
&gt; //RESAMPLE IMAGE<br>
&gt;<br>
&gt; //Define filter, create one instance<br>
&gt;<br>
&gt; typedef itk::ResampleImageFilter&lt; InternalImageType, InternalImageType
&gt;<br>
&gt; ResampleFilterType; <br>
&gt;<br>
&gt; ResampleFilterType::Pointer resampler = ResampleFilterType::New();<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; resampler-&gt;SetInput( inputImage );<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; //MORE CODE HERE TO SET RESAMPLER PARAMETERS &#8230; <br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; //CAST IMAGE TO OUTPUT TYPE<br>
&gt;<br>
&gt; typedef itk::CastImageFilter&lt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InternalImageType,<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ImageType &gt; CastFilterType; <br>
&gt;<br>
&gt; CastFilterType::Pointer &nbsp;caster = &nbsp;CastFilterType::New();<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; caster-&gt;SetInput( resampler-&gt;GetOutput() );<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; //WRITE OUTPUT FILE<br>
&gt;<br>
&gt; typedef itk::ImageFileWriter&lt; ImageType &gt; &nbsp;WriterType; <br>
&gt;<br>
&gt; WriterType::Pointer &nbsp; &nbsp; &nbsp;writer = &nbsp;WriterType::New();<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; writer-&gt;SetFileName( fileName );<br>
&gt;<br>
&gt; writer-&gt;SetInput( caster-&gt;GetOutput() );<br>
&gt;<br>
&gt; writer-&gt;Update(); <br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --------------------------------------------------------<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
----------------------------------------------------------------<br>
Este mensaje ha sido enviado desde <a href="https://webmail.unav.es/"
target="_blank">https://webmail.unav.es</a><br>
<br>
_______________________________________________<br>
Insight-users mailing list<br>
<a href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a><br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br>
_______________________________________________<br>
Insight-users mailing list <br>
<a href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a><br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a>
<o:p></o:p></span></font></p>

</div>

</div>

</div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

</div>

</div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

</div>

</div>

</div>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>