title: Hough transform R PET package detecting a line
body: <p>I have image as below and i want to detect the line in the image using PET package's hough tranform. I need help to understand how to get the line from that image.</p>
  
  <pre><code>library("PET", lib.loc="~/R/win-library/3.1")
  library("raster", lib.loc="~/R/win-library/3.1")
  
  p=matrix(diag(100), 100)
  library(raster)
  r &lt;- raster(p)
  plot(r)
  abc=hough(p)
  
  viewData(list(p, abc$hData), list("Phantom", "Hough transformed phantom"))
  </code></pre>
  
  <p>I applied hough transformation as above. The original image and image that i get after running the last line are as below<img src="https://i.stack.imgur.com/JqXVG.jpg" alt="enter image description here"><img src="https://i.stack.imgur.com/kuoA7.jpg" alt="enter image description here"></p>
  
  <p>any inputs on how to get line's coordinates (from original image)? I understand that white point from the second image right side pane represents the line. That line is plotted using Polar Cordinate system. But i dont know how to use the second image to get coordinate of the original line</p>
  
  <p>I looked at PET package's documentation but found it hard to understand :( I ran their sample code but i didn't understand it</p>
  
  <p>==============================================================================</p>
  
  <p>I followed advice given in comments by user NicE and updated my code as below</p>
  
  <pre><code>library("PET", lib.loc="~/R/win-library/3.1")
  library("raster", lib.loc="~/R/win-library/3.1")
  
  #p=matrix(diag(1000), 1000)
  p=matrix(rep(0,10000), 100, 100)
  # for (i in 1:100)
  # {p[i,100-i+1]=1
  # }
  for (i in 1:100)
  {p[i,50]=1
  }
  
  
  # library(raster)
  # r &lt;- raster(p)
  # plot(r)
  abc=hough(p)
  
  maxPoint&lt;-which(abc$hData==max(abc$hData),arr.ind=T)
  library(pracma)
  a&lt;-cot(maxPoint[1,"row"]*pi/180)
  b&lt;-maxPoint[1,"col"]/sin(maxPoint[1,"row"]*pi/180)
  a
  b
  par(pty="s")
  par(mfrow=c(1,2))
  #image(r, main="org")
  image(p,main="original")
  image(abc$hData, main="Houghmatrix")
  </code></pre>
  
  <p>Are new values of a and b correct? I feel that b should be 50 (perpendicular distance of the original line from the (0,0)). What am I doing wrong?</p>
  
  <p>I would also like to know why does abc$hData has 181 rows and 143 columns. I can imagine 181 rows has something to do with PI radians is 180 degrees. But I dont have any clue about 143 columns...</p>
  
  <p>=======================================================================
  update 2
  If i update my original matrix as I feel that i get weird answers. I get a=-57.6 and b=1786.12. </p>
  
  <pre><code>p=matrix(rep(0,10000), 100, 100)
  
  for (i in 1:100)
  {p[80,i]=1
  }
  </code></pre>