unknown parameters in Radon transform example
2 views (last 30 days)
Show older comments
in https://www.mathworks.com/help/images/detect-lines-using-the-radon-transform.html line 31 of example code: [x1,y1] = pol2cart(deg2rad(1),5000) , where 5000 comes from? the same line 34, [x91,y91] = pol2cart(deg2rad(91),100) - where 100 comes from?
[SL: fixed URL by removing trailing comma]
0 Comments
Accepted Answer
Star Strider
on 28 Aug 2024
Considering the complete example —
I = fitsread("solarspectra.fts");
I = rescale(I);
figure
imshow(I)
title("Original Image")
BW = edge(I);
figure
imshow(BW)
title("Edges of Original Image")
theta = 0:179;
[R,xp] = radon(BW,theta);
figure
imagesc(theta,xp,R)
colormap(hot)
xlabel("\theta (degrees)")
ylabel("x^{\prime} (pixels from center)")
title("R_{\theta} (x^{\prime})")
colorbar
figure
imagesc(theta,xp,R)
colormap(hot)
xlabel("\theta (degrees)")
ylabel("x^{\prime} (pixels from center)")
title("R_{\theta} (x^{\prime})")
colorbar
R_sort = sort(unique(R),"descend");
[row_peak,col_peak] = find(ismember(R,R_sort(1:5)));
xp_peak_offset = xp(row_peak);
theta_peak = theta(col_peak);
centerX = ceil(size(I,2)/2)
centerY = ceil(size(I,1)/2)
figure
imshow(I)
hold on
scatter(centerX,centerY,50,"bx",LineWidth=2)
[x1,y1] = pol2cart(deg2rad(1),5000)
PlotArgsX = [centerX-x1 centerX+x1]
PlotArgsY = [centerY+y1 centerY-y1]
plot([centerX-x1 centerX+x1],[centerY+y1 centerY-y1],"r--",LineWidth=2)
[x91,y91] = pol2cart(deg2rad(91),100)
for i=1:3
plot([centerX-x91+xp_peak_offset(i) centerX+x91+xp_peak_offset(i)], ...
[centerY+y91 centerY-y91], ...
"r",LineWidth=2)
end
plot([centerX-x91 centerX+x91],[centerY+y91 centerY-y91],"g--",LineWidth=2)
for i=4:5
plot([centerX-x1 centerX+x1], ...
[centerY+y1-xp_peak_offset(i) centerY-y1-xp_peak_offset(i)], ...
"g",LineWidth=2)
end
axlims = axis
The ‘5000’ value appears to me to be arbitrary, since (for whatever reason) it does not plot beyond the axes limits (coutrely provided by the added axis result) as I would normally expect it to, for example —
figure
plot([centerX-x1 centerX+x1],[centerY+y1 centerY-y1],"r--",LineWidth=2)
hold on
plot(axlims([1 2]), axlims(3)*[1 1], '-g')
plot(axlims([1 2]), axlims(4)*[1 1], '-g')
plot(axlims([1 2]), axlims(3)*[1 1], '-g')
plot(axlims(1)*[1 1], axlims([3 4]), '-g')
plot(axlims(2)*[1 1], axlims([3 4]), '-g')
hold off
grid
legend('Red Dashed Line', 'imshow Axes', 'Location','NE')
Experimenting with thee code and changing to ‘5000’ value to ‘500’ instead does not change the appearsnce of the red dashed line in the imshow plot.
The second pol2cart call seems to me to be more reasonable, in that its results are within the axis limits, however I suspect the ‘100’ is also arbitrary, although more appropriate to the axis scaling.
.
0 Comments
More Answers (1)
Image Analyst
on 28 Aug 2024
Edited: Image Analyst
on 28 Aug 2024
"The page you were looking for does not exist. Use the search box or browse topics below to find the page you were looking for."
help pol2cart
The 5000 and 100 were the radius they chose. I don't know why since the page you gave no longer exists.
For what it's worth, you can see my attached radon demo.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!