[Insight-users] Error while trying to read a vector image using VariableLengthVector

ravikiranj ravikiran.j.127 at gmail.com
Sat Nov 19 20:22:46 EST 2011


Actually the number of values I need to write per pixel varies from 0..5000
but the average number of components per pixel maybe like 20-30 (highly
sparse, compared to max component = 5000). If I understand correctly, Vector
Image will first allocate 5000 components per pixel irrespective of I use it
or not (I think I know this because I'm getting out of memory error during
allocation of image). Is there a way I can write say 1 component for first
pixel, 20 components for second pixel and then 1000 components for 3rd pixel
and so on.. ? 

I set an initial vector length and try pixelValue.SetSize(newsize, false)
for variable components and write the vector image, but after reading it
back, it has the same no. of components as initial vector length. 

Regards,
 Ravikiran

P.S: Sorry for the spam of replies, I'm getting HTTP 500 on replying
somehow.

daviddoria wrote:
> 
> 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
> _____________________________________
> 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.html
> 
> 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
> 
> 

-- 
View this message in context: http://old.nabble.com/Error-while-trying-to-read-a-vector-image-using-VariableLengthVector-tp32858761p32868864.html
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list