[Insight-users] How can I read a pixel from a VectorImage

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Jan 17 09:04:59 EST 2013


Ariel,

Please respond to all to include the mailing list so that all may benefit.

I agree you certainly should be able to set and get a vector pixel type, I'll try to make that happen in the next week or so. 

However, I must warn you that this is not a very fast approach for any interpretive language. You really should avoid iterating in Python on all the pixels unless the image is of trivial size. Using a tuple to perform computation is an additional burden too. Generally it mean looping those nested elements too.

There is a very large selection of image operators, and function available. There is a good chance you can do the majority of you computation on the whole image at once. Which will be significantly more efficient. Take for example the function below to generate a Marschner-Lobb function.

def marschner_lobb(size=40, alpha=0.25, f_M=6.0):
    img = sitk.PhysicalPointSource( sitk.sitkVectorFloat32, [size]*3, [-1]*3, [2.0/size]*3)
    imgx = sitk.VectorIndexSelectionCast(img, 0)
    imgy = sitk.VectorIndexSelectionCast(img, 1)
    imgz = sitk.VectorIndexSelectionCast(img, 2)
    del img
    r = sitk.Sqrt(imgx**2 + imgy**2)
    del imgx, imgy
    pr = sitk.Cos((2.0*math.pi*f_M)*sitk.Cos((math.pi/2.0)*r))
    return (1.0 - sitk.Sin((math.pi/2.0)*imgz) + alpha*(1.0+pr))/(2.0*(1.0+alpha))


If there is some specific computation that you are trying todo, please describe it so I perhaps can recommend a sequence of filters and operator to accomplish it.

Brad



On Jan 17, 2013, at 3:34 AM, Ariel Hernán Curiale <curiale at gmail.com> wrote:

> Hi Bradley,
> 
> Thanks for your reply. I'm using SimpleITK version 0.5.1. I just want to have a way to read the pixel value to perform some computation and create another image with this value (another VectorImage) I prefer to obtain a python tuple or a list like the Image.GetSize().
> 
>  Pd: I'll try later the 0.6rc1 version.
> Thanks
> __________________________________
> | Ariel Hernán Curiale Ph.D Student
> | ETSI Telecomunicación
> | Universidad de Valladolid
> | Campus Miguel Delibes
> | 47011 Valladolid, Spain
> | Phone: 983-423000 ext. 5590
> | Web: www.curiale.com.ar
> |_________________________________
> 
> El 16/01/2013, a las 20:25, Bradley Lowekamp escribió:
> 
>> Hello,
>> 
>> What version of SimpleITK are you using?
>> 
>> With 0.6rc1 there have been major improvements to support multi-dimensional slice based indexing. Which incorporates start:stop:stride, for the physical dimensions not the vector components. It appears that there may been some regression in behavior with the GetPixel method... What are you currently able to get a scalar component value? And you say you expect a "vector value" do you want a wrapped std::vector, a python tuple, or what?
>> 
>> As a couple people have asked me about the slice based indexing and vector images. I am thinking that maybe the should be done before the 0.6 release is done.
>> 
>> Please let me know what you need and expect the behavior to be.
>> 
>> Thanks,
>> Brad
>> 
>> 
>> 
>> On Jan 16, 2013, at 12:56 PM, Ariel Hernán Curiale <curiale at gmail.com> wrote:
>> 
>>> Hi all,
>>> 
>>> This is my first time with SimpleITK and looks really great. I'm trying to use it for a quick developments (SimpleITK + Python) but I don't know how I can get the pixel value of a VectorImage. Could Anyone give some tips about it ?
>>> Is there a way to get the vector instead a single value or I need to use a filter to get the vector value ? 
>>>  
>>> Thanks a lot,
>>> __________________________________
>>> | Ariel Hernán Curiale Ph.D Student
>>> | ETSI Telecomunicación
>>> | Universidad de Valladolid
>>> | Campus Miguel Delibes
>>> | 47011 Valladolid, Spain
>>> | Phone: 983-423000 ext. 5590
>>> | Web: www.curiale.com.ar
>>> |_________________________________
>>> 
>>> _____________________________________
>>> 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.php
>>> 
>>> 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
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130117/ad3a0737/attachment.htm>


More information about the Insight-users mailing list