[Insight-users] Streaming I/O
Mathieu Malaterre
Mathieu.Malaterre@creatis.insa-lyon.fr
Tue, 08 Apr 2003 18:02:36 +0200
Ron,
As I have also been struggling to understand what were the differences
between those regions I'll suggest you to have a look at:
InsightDocuments/Developer/General/itkImage.PPT
HTH
mathieu
Ron Inbar wrote:
> Hi James,
>
>
>
> Can you please explain the role of the IORegion in relation to the three
> Image Regions (Requested, Buffered, and LargestPossible)?
>
>
>
> So far, my understanding was that the ImageFileWriter should set the
> IORegion to the BufferedRegion in order to tell the ImageIO where (on
> the disk) to write the contents of the buffer. For example, if the file
> format dictates that each z-slice reside in a separate file, using some
> consistent naming scheme, then the ImageIO should use the 3^rd dimension
> of the IORegion to know which files it has to modify. It may assume
> that the data are contiguous and that the buffer size matches the size
> of the IORegion.
>
> Likewise, the ImageFileReader should set the IORegion to the
> RequestedRegion and allocate a buffer to match this size. The ImageIO
> should then use the IORegion to find the requested data on the disk and
> place them (contiguously) into the supplied buffer.
>
> The ImageIO may also need to use the m_Dimensions member to figure out
> where the data reside on the disk.
>
> To sum up, I thought the data can be assumed to be contiguous in memory,
> but not necessarily on the disk.
>
>
>
> Is this not what you had in mind?
>
>
>
> Ron
>
>
>
>
>
>
>
> -----Original Message-----
> *From:* Miller, James V (Research) [mailto:millerjv@crd.ge.com]
> *Sent:* Tuesday, April 08, 2003 4:24 PM
> *To:* 'Ron Inbar'; 'Insight-users@public.kitware.com'
> *Subject:* RE: [Insight-users] Streaming I/O
>
>
>
> This is a problem with out current IO structure. In my opinion, the
> region that should be written to disk should be the RequestedRegion (or
> at worst the BufferedRegion). Having it set to the
> LargestPossibleRegion is a problem because you do not know whether the
> pipeline actually gave you a buffer that contains the LargestPossibleRegion.
>
>
>
> I think there is a level of communication that is missing between the
> FileWrite/FileReader and the IO objects. From what I can deduce from
> the code, the IO objects assume that the IORegion maps to a contiguous
> block of
>
> memory in a buffer. The pipeline mechanism doesn't necessarily ensure
> that is the case. The only region that is contiguous in memory is the
> BufferedRegion. So we either have to stick with this assumption and be
> forced to copy the RequestedRegion to a contiguous block of memory
> sometimes or we need expand the IO objects to understand
>
> that the IORegion is only a piece of a bigger buffer.
>
>
>
> I believe you had another streaming question as well. A few months ago,
> I added methods to the IO objects
>
> CanStreamRead()/CanStreamWrite(). The current IO objects always return
> false for these methods because
>
> they do not support streaming. When we have an IO object that supports
> streaming, they will need to respond
>
> true to these methods. I think I put a call to CanStreamRead() in
> ImageFileReader but I am not sure I put a corresponding call in
> ImageFileWriter. I look into that.
>
>
>
> Jim
>
>
>
>
>
> -----Original Message-----
> *From:* Ron Inbar [mailto:ron@mediguide.co.il]
> *Sent:* Tuesday, April 08, 2003 6:32 AM
> *To:* 'Insight-users@public.kitware.com'
> *Subject:* [Insight-users] Streaming I/O
>
> 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.**
>
> **
> **
> *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.*
--
Mathieu Malaterre
CREATIS
28 Avenue du Doyen LEPINE
B.P. Lyon-Montchat
69394 Lyon Cedex 03
http://www.creatis.insa-lyon.fr/~malaterre/