Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
305 views
in Technique[技术] by (71.8m points)

python - I am Writing a code for Hough Transform. Trying to make hough space

I am Writing a code for Hough Transform. I have tried to map the pixels from edge extracted image to hough space but there is some error in the code and I cannot figure out why. I am using slope-intercept form for hough space y=mx+c. I am extracting edges of image and then points where there are non zeros pixels in edge extracted image I am mapping them

import math
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('2e.jpg',)
edge_img = cv2.Canny(img,50,200)
img_shape = edge_img.shape

x_max = img_shape[0]
y_max = img_shape[1]

#Using slope intercept form y=mx+c
#For Houghspace c=-mx+y x and y are from edge extracted image
c = 200
m = 300

hough_space = np.zeros((1000,1000))

for x in range(x_max):
    for y in range(y_max):
        if img[x,y,0] == 255: continue
        for itheta in range(m):
            c=(-1*m*x)+y
            hough_space[c,m] = hough_space[c,m] + 1

plt.imshow(hough_space, origin='lower')
plt.xlim(0,m)
plt.ylim(0,c)
question from:https://stackoverflow.com/questions/66046302/i-am-writing-a-code-for-hough-transform-trying-to-make-hough-space

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...