Axis limits based on image dimensions

5 visualizaciones (últimos 30 días)
Lauren
Lauren el 29 de Sept. de 2016
Comentada: Lauren el 5 de Oct. de 2016
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.

Respuesta aceptada

KSSV
KSSV el 30 de Sept. de 2016
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');

Más respuestas (0)

Categorías

Más información sobre Geographic Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by