# Match axis director image and plot

4 ビュー (過去 30 日間)
Alejandro Fernández 2020 年 7 月 17 日
Hello there. See if anyone knows where I can find the answer to my question or see if anyone knows how to solve it. In this case I have the cameraman image with size 7000X7000 pixels. And i need to plot one point over the image. The point has de coordinates [2000,1000] And what i need to obtain in the image is the point in this location (I know that the image Y Axis is not the same), so in this case, to obtapin the same point it should be [2000 6000]. But i suposse that it has to be one way to do it easy if I have 10000 points to put over the image.
In summary, if I have the image I and the point [2000 1000] what I expect to obtain is this: Thank you so much in advance.

サインインしてコメントする。

### 採用された回答

Nitin Kapgate 2020 年 8 月 14 日
The following code snippet and the function will help you to establish the correspondence between the points in regular cartesian coordinates in first quadrant and the location of the same point in Image coordinate system.
% X and Y coordinates of points (Let's call them as xCart and yCart respectively)
% and the corresponding X and Y coordinates in the Image coordinate system (Let's call them as xImg and yImg respectively)
% Assuming xCart and yCart lie only in the first quadrant and the input
xCart = 2000;
yCart = 1000;
% Get the X and Y coordinates in the Image coordinate system
[xImg,yImg] = returnImgCoordinates(xCart, yCart);
% Display xImg and yImg
xImg
yImg
% To access the image at these coordinates (im Image coordinate system),
% use the following code.
pixelValueAtLoc = I(xImg,yImg)
function [xImg,yImg] = returnImgCoordinates(xCart, yCart)
% The function can be used to establish the correspondence between the points in
% regular cartesian coordinates in first quadrant and the location of the same point
% in Image coordinate system.
% Use the following conversion logic to convert X and Y coordinates of
% points (Let's call them as xCart and yCart respectively) to the corresponding X and Y coordinates
% in the Image coordinate system (Let's call them as xImg and yImg respectively)
% Assuming xCart and yCart lie only in the first quadrant and the input
% Assuming that the image is 7000*7000 pixels
xImg = xCart; % Because in both the coordinate systems, X axis is in the same direction
yImg = 7000 - yCart; % The Y axes in the two coordinate sytems are in the opposite direction
end

#### 1 件のコメント

Alejandro Fernández 2020 年 8 月 14 日
Thank you so much!

サインインしてコメントする。

R2020a

### Community Treasure Hunt

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

Start Hunting!