# How to get output of HoughTransform2DLinesImageFilter() ?

**URL:** https://discourse.itk.org/t/how-to-get-output-of-houghtransform2dlinesimagefilter/4059
**Category:** Beginner Questions
**Tags:** python
**Created:** [April 22, 2021, 12:58pm UTC](https://discourse.itk.org/t/how-to-get-output-of-houghtransform2dlinesimagefilter/4059 "2021-04-22T12:58:15Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![YMarth](https://discourse.itk.org/letter_avatar_proxy/v4/letter/y/c5a1d2/32.png) [@YMarth](https://discourse.itk.org/u/YMarth)
#### Post date: [April 22, 2021, 12:58pm UTC](https://discourse.itk.org/t/how-to-get-output-of-houghtransform2dlinesimagefilter/4059/1 "2021-04-22T12:58:15Z")

</div>

I am trying to use Hough Lines transform on some iage with itk on python (spyder).  
I used the given example here:  
[How to deal with HoughTransform2DLinesImageFilter GetLines() method in python - Beginner Questions - ITK](https://discourse.itk.org/t/how-to-deal-with-houghtransform2dlinesimagefilter-getlines-method-in-python/1861)  
but I have the same problem. Here the code to make reading easier:  
##Houghlines##  
edges = sobslice #image itk.image(itk.F,2)  
houghF = itk.HoughTransform2DLinesImageFilter[itk.F, itk.F].New()  
houghF.SetInput(edges)  
houghF.SetAngleResolution(100)  
houghF.SetNumberOfLines(2)  
houghF.Update()  
DetectedLines=houghF.GetLines()  
print(DetectedLines[0].GetPoints())

## 

DetectedLines is a “Swig object of type std::vector” from which I can’t access data. At least, I know its size (with len() or .size()) but I can’t access value with GetPoint().  
Any idea ?  
Thanks !

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 22, 2021, 3:55pm UTC](https://discourse.itk.org/t/how-to-get-output-of-houghtransform2dlinesimagefilter/4059/2 "2021-04-22T15:55:22Z")

</div>

Does `DetectedLines[0].GetPoints()[0]` work?

---

<div class="post-metadata">

### Author: ![YMarth](https://discourse.itk.org/letter_avatar_proxy/v4/letter/y/c5a1d2/32.png) [@YMarth](https://discourse.itk.org/u/YMarth)
#### Post date: [April 23, 2021, 7:46am UTC](https://discourse.itk.org/t/how-to-get-output-of-houghtransform2dlinesimagefilter/4059/3 "2021-04-23T07:46:06Z")

</div>

> [@dzenanz](#):
>
> `DetectedLines[0].GetPoints()[0]`

Unfortunately no, I still have a ‘proxy of a swig object’ and not a value.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 23, 2021, 1:27pm UTC](https://discourse.itk.org/t/how-to-get-output-of-houghtransform2dlinesimagefilter/4059/4 "2021-04-23T13:27:56Z")

</div>

Does `DetectedLines[0].GetPoint(0)` work? `DetectedLines[0]` is a [LineSpatialObject](https://itk.org/Doxygen/html/classitk_1_1LineSpatialObject.html).

@nick did you get it working, and how?

---

<div class="post-metadata">

### Author: ![YMarth](https://discourse.itk.org/letter_avatar_proxy/v4/letter/y/c5a1d2/32.png) [@YMarth](https://discourse.itk.org/u/YMarth)
#### Post date: [April 23, 2021, 3:34pm UTC](https://discourse.itk.org/t/how-to-get-output-of-houghtransform2dlinesimagefilter/4059/5 "2021-04-23T15:34:10Z")

</div>

Neither,it gives the same kind of output that .GetPoints(). I would expect an array with some coordinate, an angle and a distance as it is what the Hough transform should compute.  
I read the page you linked with LineSpatialObject. The method “PrintSelf()” is not working (error), may be it coul be a way to retrieve the value ?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 23, 2021, 3:35pm UTC](https://discourse.itk.org/t/how-to-get-output-of-houghtransform2dlinesimagefilter/4059/6 "2021-04-23T15:35:27Z")

</div>

Maybe `print(DetectedLines[0])`?

---

<div class="post-metadata">

### Author: ![YMarth](https://discourse.itk.org/letter_avatar_proxy/v4/letter/y/c5a1d2/32.png) [@YMarth](https://discourse.itk.org/u/YMarth)
#### Post date: [April 23, 2021, 3:51pm UTC](https://discourse.itk.org/t/how-to-get-output-of-houghtransform2dlinesimagefilter/4059/7 "2021-04-23T15:51:11Z")

</div>

Thought I already tried this one but may be I only tried “print(DetectedLines)” and “print(DetectedLines[0].GetPoints)”.  
It gives something at least, some info on the object (size) plus some on the region but I don’t know which region ! I have also info on “Family Bounding Boxes of Spatial Object”. I don’t see something which looks like a couple (distance, angle).[Output\_printDetectedLines.txt](https://discourse.itk.org/uploads/short-url/w7SZzUpbcVCgS54NJeKMJInE5Th.txt) (3.8 KB)

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [May 4, 2021, 3:00am UTC](https://discourse.itk.org/t/how-to-get-output-of-houghtransform2dlinesimagefilter/4059/8 "2021-05-04T03:00:51Z")

</div>

To get the [LineSpatialObjectPoint](https://itk.org/Doxygen/html/classitk_1_1LineSpatialObjectPoint.html):

```auto
point = DetectedLines[0].GetPoint(0)

```

This has methods:

```auto
print(point.GetPositionInObjectSpace())
print(point.GetPositionInWorldSpace())
print(point.GetNormalInObjectSpace(0))

```
