4

How do I generate a Hough transform (Hough line transformation) of a binary image in QGIS?

enter image description here

enter image description here

I tried in GRASS and I got Error: unable to fetch interface description for command

I found from the link: Many GRASS add-ons do not work with QGIS?, "if you want to use an add-on, you need to install GRASS GIS and not the version installed with QGIS which is designed to work with a QGIS interface (grass plugin and processing). The error means that the plugin cannot build his GRASS interface".

I tried r.houghtransform on GRASS GIS but it yielded no results. The raster file can be accessed with the following link: https://drive.google.com/drive/folders/1YL6m41eAGEMHhBDr8hjyHa906FSKgbNQ?usp=sharing

I followed the following steps in GRASS GIS but no results was rendered:

Step 1: Import raster data> Simplified raster import with reprojection [r.import]

enter image description here

enter image description here

enter image description here

Step 2: In Console: r.houghtransform

enter image description here

Step 3: r.houghtransform User Interface

enter image description here

Step 4: Select Run

enter image description here

7
  • 1
    It seems Grass has a tool for it. grass.osgeo.org/grass78/manuals/addons/r.houghtransform.html Did you try it?
    – Nil
    Jan 10 at 14:36
  • Error in GRASS: unable to fetch interface description for command
    – HansrajR
    Jan 10 at 14:51
  • Error in GRASS GIS for Windows: 'r.thoughtransform' is not recognized as an internal or external command, operable program or batch file.
    – HansrajR
    Jan 10 at 15:15
  • Have you tried to google the error message? There are several hits if you google with a similar problem (e.g. gis.stackexchange.com/questions/293253/…)
    – Nil
    Jan 10 at 18:14
  • 1
    I found a solution: if you want to use an add-on, you need to install GRASS GIS and not the version installed with QGIS which is designed to work with a QGIS interface (grass plugin and processing). The error means that the plugin cannot build his GRASS interface" from the link: gis.stackexchange.com/questions/134031/… I tried r.houghtransform on GRASS GIS but it yielded no results. The binary raster can be accessed on the following link: drive.google.com/drive/folders/…
    – HansrajR
    Jan 10 at 18:23
1

I gave it a try with your dataset and obtained the Hough lines (note that I didn't attempt to optimize the Hough transform parameters). The computation took some 20min or so on my "average" laptop.

Result:

enter image description here

Procedure:

grass79 -c epsg:32618 ~/grassdata/epsg32618
Starting GRASS GIS...

# import GeoTIFF
GRASS epsg32618/PERMANENT:~ > r.import Binary\ Raster.tif  output=rastermap
Importing raster map <rastermap>...
 100%

# set computational region to raster map
# https://grasswiki.osgeo.org/wiki/Computational_region
GRASS epsg32618/PERMANENT:~ > g.region -p
projection: 1 (UTM)
zone:       18
datum:      wgs84
ellipsoid:  wgs84
north:      378975.8392
south:      378905.4782
west:       353507.7774
east:       353583.0939
nsres:      0.01856001
ewres:      0.01856
rows:       3791
cols:       4058
cells:      15383878

# show imported map
GRASS epsg32618/PERMANENT:~ > d.mon wx0
GRASS epsg32618/PERMANENT:~ > d.rast rastermap
 100%

# install addon https://grass.osgeo.org/grass7/manuals/addons/r.houghtransform.html
GRASS epsg32618/PERMANENT:~ > g.extension r.houghtransform
...
Installation of <r.houghtransform> successfully finished

# show the GUI
GRASS epsg32618/PERMANENT:~ > r.houghtransform --ui

# however, we continue with command line for now
GRASS epsg32618/PERMANENT:~ > r.houghtransform input=rastermap output=hough 
# ... this takes a while to compute...

# show name of resulting vector map
GRASS epsg32618/PERMANENT:~ > g.list vector
hough

# display vector Hough lines
GRASS epsg32618/PERMANENT:~ > d.vect hough color=red size=2

See above for the resulting vector map (red lines).

4
  • I edited the question with steps followed based on your recommendations but could not render any results. Can you kindly advise.
    – HansrajR
    Feb 1 at 14:38
  • You are missing before "Step 2: In Console: r.houghtransform" to set the computational region to the map. Reason: the display and the computational region are distinct from each other.
    – markusN
    Feb 1 at 15:03
  • @markusN could you show how to set the computation region in the Grass GUI? I am trying to compute hough transformations right now, but having trouble. I've only ever used Q and Arc before so having quite a time figuring it out on my own.
    – hmnoidk
    Apr 13 at 15:28
  • Please check grass.osgeo.org/grass-stable/manuals/… --> Various zoom options --> Set computational region extent from display/interactively
    – markusN
    Apr 14 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.