Skip to main content

Hough Lines

consider the image like this we need to find the lines on this image 

the basic lines would be horizontal ,vertical and inclined line 

we will try to use hough to detect using equations 

ok before that we need to understand the image co ordinate 

top left is 0,0 assume it is the third quadrant , for 

better understanding i have drawn a to show how a pixel is calculated from top left



pixel arrangement for image 


 

this is level zoom of more than 1000 , in real world u cannot see the pixel (1pixel of size 1,1) 

alright now we can need to see how to find the lines on the first image

the triangle on a zoomed in pixel wil look like this 

ok we will start with the horizontal line calculation 

since the pixel calculation is in the quadrant  i will shift or plot the values in 

the first quadrant for my calculation 

when shifted will look like this ,


for horizontal line calculation the theta of r must be at 90 degrees to the horizontal line u can see the value in diagram

r = x cos𝛳 + y sin 𝛳

calculate for [4,2] [5,2] ,[8,2 ] 

if u put random values for 𝛳 starting from  𝛳 >0 and 𝛳  <2𝞹

u could see for 𝛳 = 90

for calculation convert degrees to radians which is 0.5 *𝞹

r =  4 *cos(0.5 *𝞹) + 2 sin (0.5 *𝞹)

= 0 + 2 =2

r =  5 *cos(0.5 *𝞹) + 2 sin (0.5 *𝞹)

 = 0 + 2 =2

so it says for the  𝛳 = 90 r = 2 for these points so according to hough 

it means they lie on the same line which is in our case is the horizontal line.


moving on to the inclined line from the diagram u can see the 𝛳 = 315

so the calculation for the pixel on the slope 

[4,3] [5,4] [7,6]

 r =  4 *cos(1.75 *𝞹) + 3 sin (1.75 *𝞹)

= 0.7 

r =  7 *cos(1.75 *𝞹) + 6 sin (1.75 *𝞹)= 0.7 

so at an angle of  𝛳 = 315 and r =0.7 which is a small line as u can see in the diagram ,the line which is at right angles to this line r would be the

inclined line where the above point lie .

enjoy


Comments

Popular posts from this blog

Node and Auth0 - Integration

 so now we have completed all the steps for integration  since we have the node and auth0 as two separate things the integration happens in the app.js  we need to modify the app.js with some auth0 code  app.js / const http = require('http'); const express = require('express'); var router = require('express').Router(); const { auth } = require('express-openid-connect'); const app = express(); app.use('/', router); const hostname = '127.0.0.1'; const port = 3000; http.createServer(app)   .listen(port, () => {     console.log(`Listening on `);   }); const config = {   authRequired: false,   auth0Logout: true,   secret: 'a long, randomly-generated string stored in env',   baseURL: 'http://localhost:3000',   clientID: 'QxpAXsXkzy0Vm2VdT6dFFS0VOKdrah67',   issuerBaseURL: 'https://dev-bnga041p.us.auth0.com' }; console.log(config) // auth router attaches /login, /logout, and /callback routes to the baseURL app.u

Auth0

You might be wondering what is this auth0  it is used for authentication of you applications  could be any apps  1.SPA - Angular , React  2.web app 3.Node  here we will talk about the node use case and go with example  moving ahead for now  if your are not familiar with node dont worry its a funny exercise for now walk with me  we dont have to worry too much for authentication as the service is  provided from auth0   create your node app  install node  https://nodejs.org/en/download/package-manager/  choose your os and do the installation once installed check for the version ' node -v  ' i assume u have installed so that u wil get the version for now  since iam using LINUX this will look like root@strings-desktop:/home/strings/js# node -v v16.13.0 moving on to creating node app for now    create a file app.js and paste the contents  app.js/ const http = require('http'); const express = require('express'); const app = express(); const hostname = '127.0.0.1&#