Axis limits based on image dimensions

조회 수: 5 (최근 30일)
Lauren
Lauren 2016년 9월 29일
댓글: Lauren 2016년 10월 5일
I want to plot (x,y) on an image, where the image is my "scale". For instance, I need the left edge to be 0 and the right edge to be 450 on the x axis. The bottom edge to be 0 and the top edge to be 100 on the y axis. Then, if I plot(225,50), there will be a point plotted in the middle of the image.
I have two examples of what I have so far. 1) This script plots onto the image and shows the whole image, but the axis is incorrect. The top edge is 0, instead of the bottom edge and the right edge is a random number that is not defined by me.
clear all; close all
crosssection = imread('SplitViewPrt.JPG');
figure(1);
image(crosssection);
axis equal;
truesize(figure(1))
hold on;
x = [0 100 200 450];
y = [10 25 50 0];
plot (x,y,'or')
2) This second example shows the axis limits are properly set (except that the y axis is still in the wrong direction), but it crops the image and zooms in so that the right edge is no longer the actual right edge of the image.
clear all; close all
crosssection = imread('SplitViewPrt.JPG');
figure(1);
image(crosssection);
axis equal;
truesize(figure(1))
hold on;
axis([0, 514.873, 0, 147.6757])
x = [0 100 200 450];
y = [10 25 50 0];
plot (x,y,'or')
What I need is very similar to a map, but it's not based on latitude and longitude. Does anyone know how to "map" on something that's not an actual geographic map? Any idea how to help?
Thanks.

채택된 답변

KSSV
KSSV 2016년 9월 30일
You may use : image('XData',x,'YData',y,'CData',C)
Eg:
I = imread('cameraman.tif');
h1 = axes ;
image('XData',[-180 180],'YData',[90 -90],'CData',I) ; % set your limits
set(h1,'YDir','normal');
  댓글 수: 1
Lauren
Lauren 2016년 10월 5일
This is very helpful!
Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by