开发者

Matlab - how to draw scaled figures on an image

I have an image with 4 spots on it, I want those spots to line up exactly(or very close) to X,Y coordinates in a figure 开发者_运维知识库that I would like to draw on top of this image. The image is currently 600x600 pixels, but that could be adjusted.

My figure scale goes from

AXIS([388020 388090 5776940 5777010])

How can I align my image to match that? So matlab draws on top of it?

Here is my matlab script, running this I can see the matlab drawing but no image underneath... and the matlab drawing seems to be inverted.

%takes in csv file %for each line outputs an image that includes 3 circles and the estimated %point

d = size(dataAdjusted) length = d(1)

for 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');

end


You can call both image() and imagesc() with x,y limits which are then used as the axis limits:

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

or, if you just need scaled data:

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

You may need to issue a 'hold all' once you've put up the image, before ploting anything else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜