1

我有一个上面有 4 个点的图像,我希望这些点与我想在该图像顶部绘制的图形中的 X、Y 坐标完全对齐(或非常接近)。该图像当前为 600x600 像素,但可以进行调整。

我的身材比例来自

AXIS([388020 388090 5776940 5777010])

如何对齐我的图像以匹配它?所以matlab在它上面绘制?

这是我的 matlab 脚本,运行它我可以看到 matlab 绘图,但下面没有图像……而且 matlab 绘图似乎是倒置的。

%takes in csv file %for 每行输出一个包含 3 个圆圈和估计的 %point 的图像

d = 大小(数据调整)长度 = d(1)

对于 i = [1:1]

%# read and display image
img = imread('hciLab_N.png');
figure('Visible', 'off'),imagesc([388020 388090], [5776940 5777010], img);    

%# make sure the image doesn't disappear if we plot something else
hold on

%axis([388020 388090 5776940 5777010]);

%location estimation
yCoord = dataAdjusted(i,2)
xCoord = dataAdjusted(i,3)

%first  circle y, x, radius
c1Y = dataAdjusted(i,4);
c1X = dataAdjusted(i,5);
c1R = dataAdjusted(i,6);

%second circle y, x, radius
c2Y = dataAdjusted(i,7);
c2X = dataAdjusted(i,8);
c2R = dataAdjusted(i,9);

%third  circle y, x, radius
c3Y = dataAdjusted(i,10);
c3X = dataAdjusted(i,11);
c3R = dataAdjusted(i,12);


%draw location
%rectangle('Position',[xCoord-.5,yCoord-.5,2*.5,2*.5],'Curvature',[1,1], 'EdgeColor', 'r')
[locX, locY] = makeCircle(xCoord, yCoord, .5);
scatter(locX, locY, .2,'b')

%draw circles
%rectangle('Position',[c1X-c1R,c1Y-c1R,2*c1R,2*c1R],'Curvature',[1,1])
%rectangle('Position',[c2X-c2R,c2Y-c2R,2*c2R,2*c2R],'Curvature',[1,1])
%rectangle('Position',[c3X-c3R,c3Y-c3R,2*c3R,2*c3R],'Curvature',[1,1])
[c1X, c1y] = makeCircle(c1X, c1Y, c1R);
scatter(c1X, c1y, .2,'k')
[c2X, c2y] = makeCircle(c2X, c2Y, c2R);
scatter(c2X, c2y, .2,'k')
[c3X, c3y] = makeCircle(c3X, c3Y, c2R);
scatter(c3X, c3y, .2,'k')


% 80 5776978.148    388054.1747
%rectangle('Position',[388054.1747-1,5776978.148-1,2*1,2*1],'Curvature',[1,1], 'EdgeColor', 'g')
[r1X, r1y] = makeCircle(388054.1747, 5776978.148, 1);
scatter(r1X, r1y,.2,'g')


% 87 5776988.825    388043.9639
%rectangle('Position',[388043.9639-1,5776988.825-1,2*1,2*1],'Curvature',[1,1], 'EdgeColor', 'g')
[r2X, r2y] = makeCircle(388043.9639, 5776988.825, 1);
scatter(r2X, r2y,.2,'g')


% 88 5776970.712    388054.2578
%rectangle('Position',[388054.2578-1,5776970.712-1,2*1,2*1],'Curvature',[1,1], 'EdgeColor', 'g')
[r3X, r3y] = makeCircle(388054.2578,5776970.712, 1);
scatter(r3X, r3y,.2,'g')


% 89 5776975.889    388039.8496
%rectangle('Position',[388039.8496-1,5776975.889-1,2*1,2*1],'Curvature',[1,1], 'EdgeColor', 'g')
[r4X, r4y] = makeCircle(388039.8496,5776975.889, 1);
scatter(r4X, r4y,.2,'g')


%title(['Localization of duty cycle ' this_name ]);
saveas(gcf, ['TrilaterationNumber_Adjusted_WithRouters_Scaled' num2str(i)], 'png');

结尾

4

1 回答 1

1

您可以使用 x,y 限制调用image()imagesc(),然后将其用作轴限制:

data = makeImage();
image([x0 x1],[y0 y1],data);
axis('xy');

或者,如果您只需要缩放数据:

data = makeData();
imagesc([x0 x1], [y0 y1], data);
axis('xy');
colorbar;

一旦你放置了图像,在绘制其他任何东西之前,你可能需要发出“保留所有”。

于 2011-06-22T01:14:18.857 回答