unknown parameters in Radon transform example

조회 수: 2 (최근 30일)
Marek
Marek 2024년 8월 28일
답변: Star Strider 2024년 8월 28일
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]

채택된 답변

Star Strider
Star Strider 2024년 8월 28일
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)
centerX = 96
centerY = ceil(size(I,1)/2)
centerY = 83
figure
imshow(I)
hold on
scatter(centerX,centerY,50,"bx",LineWidth=2)
[x1,y1] = pol2cart(deg2rad(1),5000)
x1 = 4.9992e+03
y1 = 87.2620
PlotArgsX = [centerX-x1 centerX+x1]
PlotArgsX = 1x2
1.0e+03 * -4.9032 5.0952
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
PlotArgsY = [centerY+y1 centerY-y1]
PlotArgsY = 1x2
170.2620 -4.2620
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
plot([centerX-x1 centerX+x1],[centerY+y1 centerY-y1],"r--",LineWidth=2)
[x91,y91] = pol2cart(deg2rad(91),100)
x91 = -1.7452
y91 = 99.9848
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
axlims = 1x4
0.5000 192.5000 0.5000 165.5000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
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.
.

추가 답변 (1개)

Image Analyst
Image Analyst 2024년 8월 28일
편집: Image Analyst 2024년 8월 28일
"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
POL2CART Transform polar to Cartesian coordinates. [X,Y] = POL2CART(TH,R) transforms corresponding elements of data stored in polar coordinates (angle TH, radius R) to Cartesian coordinates X,Y. The arrays TH and R must have compatible sizes. In the simplest cases, they can be the same size or one can be a scalar. Two inputs have compatible sizes if, for every dimension, the dimension sizes of the inputs are either the same or one of them is 1. TH must be in radians. [X,Y,Z] = POL2CART(TH,R,Z) transforms corresponding elements of data stored in cylindrical coordinates (angle TH, radius R, height Z) to Cartesian coordinates X,Y,Z. The arrays TH, R, and Z must have compatible sizes. TH must be in radians. Class support for inputs TH,R,Z: float: double, single See also CART2SPH, CART2POL, SPH2CART. Documentation for pol2cart doc pol2cart Other uses of pol2cart distributed/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.

제품


릴리스

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by