[Insight-users] The Hough transform and world/pixel coordinates

Gomez, Alberto alberto.gomez at kcl.ac.uk
Wed Jan 27 07:00:08 EST 2010


Thanks Markus,

Using ContinuousIndex worked. Nevertheless, I still think that any itk 
Filter should always work in physical coordinates... Is there any reason 
why this filter does not, or is just for implementation easiness or 
efficiency?

Markus Neuner wrote:
> Hi Alberto Gomez,
>
> When you take a look at the source code of
> "Insight/Code/BasicFilters/itkHoughTransform2DLinesImageFilter.txx"
> starting at line 298 you can see how the points are calculated:
>
> ...
>         LineType::PointListType list; // insert two points per line
> ...
>         double radius = it_input.GetIndex()[0];
>         double teta   =
> ((it_input.GetIndex()[1])*2*nPI/this->GetAngleResolution())-nPI;
>         double Vx = radius*vcl_cos(teta );
>         double Vy = radius*vcl_sin(teta );
>         double norm = vcl_sqrt(Vx*Vx+Vy*Vy);
>         double VxNorm = Vx/norm;
>         double VyNorm = Vy/norm;
> ...
>           LinePointType p;
>           p.SetPosition(Vx,Vy);
>           list.push_back(p);
>           p.SetPosition(Vx-VyNorm*5,Vy+VxNorm*5);
>           list.push_back(p);
> ...
>
> Furthermore the points are of type "itk::LineSpatialObjectPoint<
> TPointDimension >" whith "typedef Point
> <http://www.itk.org/Doxygen/html/classitk_1_1Point.html>< double,
> TPointDimension > PointType".
> <http://www.itk.org/Doxygen/html/classitk_1_1LineSpatialObjectPoint.html#993f2f73923d9e4fc69f18ca6ac95ea4>
>
> As you can see the coordinates are of type double.
>
> The easiest solution is to construct a
>  itk::ContinuousIndex
> <http://www.itk.org/Doxygen/html/classitk_1_1ContinuousIndex.html>
> (should be defined in the ImageType::ContiunuousIndexType)
> and pass it to
> TransformContinuousIndexToPhysicalPoint (const ContinuousIndex<
> TCoordRep, VImageDimension > &        index, Point< TCoordRep,
> VImageDimension > &  point ).
>
> I hope this helps.
>
> Best regards,
> Markus
>
>
>
> Gomez, Alberto wrote:
>   
>> Hi all,
>>
>> I am using the itk::HoughTransform2DLinesImageFilter  to extract the
>> lines from an image for a certain application. The point is that I
>> don't want to draw the lines but to get the lines parameters
>> (direction and a point ) for further computations. I realised that,
>> following the example from the software guide, the vector and the line
>> are in pixel coordinates and not in real world coordinates. Can anyone
>> confirm this?
>>
>> So, what I did is to use the TransformIndexToPhysicalPoint() method,
>> but it does not work properly (mi lines are slightly deviated). My
>> assumption is that the extracted points are in pixel coordinates but
>> aren't integers. Because of that, the TransformIndexToPhysicalPoint()
>> method rounds them and then computes the physical coordinates, which
>> yields in the inaccuracy I realized.
>>
>> The solution I found was to get two points, in pixel coordinates, very
>> far from each other, so that the inaccuracy of the conversion is
>> smaller. Nevertheless, this is not clean. Does anyone know a way to
>> get the line parameters accurately in physical coordinates? I guess
>> that the Hough map (output of the filter) is (r, theta) in real
>> physical coordinates, but I don't know how to extract the maximums in
>> the same way that getLines() does (using the disc, etc).
>>
>> Thank you,
>> Alberto
>> ||
>>
>> -- 
>>
>> Alberto Gómez
>>
>> /Division of Imaging Sciences
>> The Rayne Institute
>> 4th Floor, Lambeth Wing
>> St Thomas' Hospital
>> London SE1 7EH /
>>
>> phone: +44 (0) 20 718 88364
>> email: alberto.gomez at kcl.ac.uk <mailto:alberto.gomez at kcl.ac.uk>
>>
>> ------------------------------------------------------------------------
>>
>> _____________________________________
>> 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
>>   
>>     
>
>   


-- 

Alberto Gómez

/Division of Imaging Sciences
The Rayne Institute
4th Floor, Lambeth Wing
St Thomas' Hospital
London SE1 7EH /

phone: +44 (0) 20 718 88364
email: alberto.gomez at kcl.ac.uk <mailto:alberto.gomez at kcl.ac.uk>



More information about the Insight-users mailing list