[Insight-users] Error while trying to read a vector image using VariableLengthVector
David Doria
daviddoria at gmail.com
Sat Nov 19 20:14:34 EST 2011
On Sat, Nov 19, 2011 at 8:09 PM, ravikiranj <ravikiran.j.127 at gmail.com> wrote:
>
> Also, whenever a vector image is instantiated, we specify a vector length
> i.e, SetVectorLength(l) which ensures that each of the pixel has the same
> length vector and I've been unsuccessful in changing the vector size
> dynamically :(. Would be possible to write a code snippet where I can write
> a variable no. of components per pixel, save it and read it back again, I've
> been stuck with this issue for a week now without any visible solution than
> writing a custom file format (text file).
This is all you need to do to create an image with pixels of dynamic
length = 4 :
typedef itk::VectorImage<float,2> VectorImageType;
VectorImageType::Pointer image = VectorImageType::New();
... setup the region of the image ...
image->SetNumberOfComponentsPerPixel(4);
You can write this with a normal ImageFileWriter<VectorImageType>.
When you read it with a normal ImageFileReader<VectorImageType> the
pixels will be automatically sized correctly to have 4 components.
David
More information about the Insight-users
mailing list