图像的情节出现偏移
我正在尝试通过导入的图像绘制圆圈和直线a = b
。该图出现了,但我遇到了两个问题:
- 图像不是中心的 - 在这里,圆圈应该位于图像的中心,
- 并带有倒置斜率
clear;close all;
I0 = imread('temp.png');
I1 = im2double(I0);
I = imresize(I1,[320 320]);
a=0:1:320;
b = a;
r=320/2;
xc=0; yc=0;
th = linspace( 0, 2*pi, 100);
x = r * cos(th) + xc;
y = r * sin(th) + yc;
figure,imshow(I)
hold on
plot(b,a,'linewidth',3)
hold on
plot(x,y,'white','linewidth',3)
sstatic.net/du3kn.png“ rel =“ nofollow noreferrer 通过绘制(b,-a,'lineWidth',3)
而不是通过图像绘制的斜率。
任何帮助都将不胜感激。是的,这是用于作业的,但根本不是最终答案:)
I'm attempting to draw a circle and a straight line a=b
over an imported image. The plot appears but I've run into two problems:
- The image is not centered - here, the circle is supposed to be in the center of the image
- The line appears with an inverted slope
clear;close all;
I0 = imread('temp.png');
I1 = im2double(I0);
I = imresize(I1,[320 320]);
a=0:1:320;
b = a;
r=320/2;
xc=0; yc=0;
th = linspace( 0, 2*pi, 100);
x = r * cos(th) + xc;
y = r * sin(th) + yc;
figure,imshow(I)
hold on
plot(b,a,'linewidth',3)
hold on
plot(x,y,'white','linewidth',3)
I can fix the slope of the line by plotting (b,-a,'linewidth',3)
instead but the line does not draw over the image.
Any help would be much appreciated. Yes this is for an assignment but it would not the final answer at all :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
点(0,0)不是图像的中心。由于您使用
imshow
显示映像i
,因此轴的大小为i
,在您的情况下,0
320
。因此,您需要根据此选择圆的中心。在下面的代码中,请参见带有注释%1
的修改线。imshow
设置轴ij
模式,用于倒入垂直轴的图像。要绘制该行通常,您可以设置XY
模式。请参阅“代码”中的注释%2
的添加行。The point (0,0) is not the center of the image. Since you are displaying the image
I
withimshow
, the axes will have the size ofI
, in your case from0
to320
. So you need to choose the center of the circle based on that. See modified line with comment%1
in the code below.imshow
sets the axisij
mode, used for images, which inverts the vertical axis. To plot the line normally you can set thexy
mode. See added line with comment%2
in the code.