Q2.3 The Hough transform (20 points) Write a function that applies the Hough Transform to an edge magnitude image. Dis-
Posted: Fri Jul 01, 2022 6:15 am
Will also need an explanation to how it works.
Q2.3 The Hough transform (20 points) Write a function that applies the Hough Transform to an edge magnitude image. Dis- play the output for one of the images in the write-up. function [H, rhoScale, thetaScale] = myHoughTransform (Im, threshold, rhoRes, thetaRes) Im is the edge magnitude image, threshold (scalar) is a edge strength threshold used to ignore pixels with a low edge filter response. rhoRes (scalar) and thetaRes (scalar) are 4 the resolution of the Hough transform accumulator along the p and axes respectively. H is the Hough transform accumulator that contains the number of "votes" for all the possible lines passing through the image. rhoScale and thetaScale are the arrays of p and values over which myHoughTransform generates the Hough transform matrix H. For example, if rhoScale(i) = p; and thetaScale (j) = 0₁, then H(i, j) contains the votes for p = P₁ and 0 = 0₁. First, threshold the edge image. Each pixel (x, y) above the threshold is a possible point on a line and votes in the Hough transform for all the lines it could be a part of. Parametrize lines in terms of and p such that p = r cos 0 + y sin 0, 0 € [0, 2π] and p = [0, M]. M should be large enough to accommodate all lines that could lie in an image. Each line in the image corresponds to a unique pair (p, 0) in this range. Therefore, values corresponding to negative p values are invalid, and you should not count those votes. The accumulator resolution needs to be selected carefully. If the resolution is set too low, the estimated line parameters might be inaccurate. If resolution is too high, run time will increase and votes for one line might get split into multiple cells in the array. Your code cannot call Matlab's hough function, or any other similar functions. You may use hough for comparison and debugging. A sample visualization of H is shown in Figure 2.