[Insight-users] Streaming I/O

Ron Inbar ron@mediguide.co.il
Tue, 8 Apr 2003 12:31:45 +0200


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C2FDBA.0DE68230
Content-Type: text/plain

In the course of my efforts to implement an ImageIO subclass that supports
streaming, I came across the following code segment (in
itkImageFileWriter.txx):

 

template <class TInputImage>

void 

ImageFileWriter<TInputImage>

::Write(void)

{

  // . . .

 

  // Make sure region is within the image, crop if necessary

  ImageIORegion ioRegion(TInputImage::ImageDimension);

  ImageRegion<TInputImage::ImageDimension> region = 

        input->GetLargestPossibleRegion();

  const double *spacing = input->GetSpacing();

  const double *origin = input->GetOrigin();

 

  m_ImageIO->SetNumberOfDimensions(TInputImage::ImageDimension);

  for(unsigned int i=0; i<TInputImage::ImageDimension; i++)

    {

    ioRegion.SetSize(i,region.GetSize(i));

    ioRegion.SetIndex(i,region.GetIndex(i));

    m_ImageIO->SetDimensions(i,region.GetSize(i));

    m_ImageIO->SetSpacing(i,spacing[i]);

    m_ImageIO->SetOrigin(i,origin[i]);

    }

  itkDebugMacro( <<"Region to write = " << ioRegion );

  this->Write(ioRegion);        

}

 

My question is: why does it set the ioRegion to the LargestPossibleRegion
and not to the BufferedRegion?

(I tried to change it and on first inspection it seems to work OK with the
BufferedRegion).

 

Ron

 


This e-mail message has been sent by MediGuide
and is for the use of the intended recipients only.
The message may contain privileged or confidential information .
If you are not the intended recipient you are hereby notified that any use,
distribution or copying of this communication is strictly prohibited,
and you are requested to delete the e-mail and any attachments
and notify the sender immediately.

------_=_NextPart_001_01C2FDBA.0DE68230
Content-Type: text/html

<html>

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">


<meta name=Generator content="Microsoft Word 10 (filtered)">

<style>
<!--
 /* 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:purple;
	text-decoration:underline;}
span.EmailStyle17
	{font-family:Arial;
	color:windowtext;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>In the course of my efforts
to implement an ImageIO subclass that supports streaming, I came across the
following code segment (in itkImageFileWriter.txx):</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>&nbsp;</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>template</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> &lt;<font color=blue><span
style='color:blue'>class</span></font> TInputImage&gt;</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>void</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> </span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>ImageFileWriter&lt;TInputImage&gt;</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>::Write(<font color=blue><span
style='color:blue'>void</span></font>)</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>{</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp; // . . .</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp; <font color=green><span
style='color:green'>// Make sure region is within the image, crop if necessary</span></font></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp; ImageIORegion ioRegion(TInputImage::ImageDimension);</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp; ImageRegion&lt;TInputImage::ImageDimension&gt;
region = </span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
input-&gt;GetLargestPossibleRegion();</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp; <font color=blue><span
style='color:blue'>const</span></font> <font color=blue><span style='color:
blue'>double</span></font> *spacing = input-&gt;GetSpacing();</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp; <font color=blue><span
style='color:blue'>const</span></font> <font color=blue><span style='color:
blue'>double</span></font> *origin = input-&gt;GetOrigin();</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp; m_ImageIO-&gt;SetNumberOfDimensions(TInputImage::ImageDimension);</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp; <font color=blue><span
style='color:blue'>for</span></font>(<font color=blue><span style='color:blue'>unsigned</span></font>
<font color=blue><span style='color:blue'>int</span></font> i=0; i&lt;TInputImage::ImageDimension;
i++)</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; {</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; ioRegion.SetSize(i,region.GetSize(i));</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; ioRegion.SetIndex(i,region.GetIndex(i));</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; m_ImageIO-&gt;SetDimensions(i,region.GetSize(i));</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; m_ImageIO-&gt;SetSpacing(i,spacing[i]);</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; m_ImageIO-&gt;SetOrigin(i,origin[i]);</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; }</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp; itkDebugMacro(
&lt;&lt;&quot;Region to write = &quot; &lt;&lt; ioRegion );</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp; <font color=blue><span
style='color:blue'>this</span></font>-&gt;Write(ioRegion);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>}</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>My question is: why does it set
the ioRegion to the LargestPossibleRegion and not to the BufferedRegion?</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>(I tried to change it and on
first inspection it seems to work OK with the BufferedRegion).</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>Ron</span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></font></p>

</div>


<DIV><STRONG><FONT color=#000080 size=2></FONT></STRONG>&nbsp;</DIV>
<DIV><STRONG><FONT color=#000080 size=2></FONT></STRONG>&nbsp;</DIV>
<DIV><STRONG><FONT color=#000080 size=2>This e-mail message has been sent by 
MediGuide</FONT></STRONG></DIV>
<DIV><STRONG><FONT color=#000080 size=2>and is for the use of the intended 
recipients only.<BR>The message may contain&nbsp;privileged or confidential 
information .<BR>If you are not the intended recipient you are hereby notified 
that any use,<BR>distribution or copying of this communication is strictly 
prohibited,<BR>and you are requested to delete the e-mail and any 
attachments</FONT></STRONG></DIV>
<DIV><STRONG><FONT color=#000080 size=2>and notify the sender 
immediately.</FONT></STRONG></DIV>
</body>

</html>

------_=_NextPart_001_01C2FDBA.0DE68230--