How to set custom origin point?
Show older comments
Hello,
I can't manage to find any solution to this problem (do I have to precise I am a complete novice with matlab):
Lets say I have an image named "image" and I show it on screen with axis. By default, my axis will be, from one border to another, zero to end (number of the last column).
But I have a point in "image" that I want to be zero, the origin. I know that point from a mouse input. How do I explain to matlab that I want this point to be the origin of the axis?
Ps: does the following script do something good? (I found it in "How to change the default origin of the axis of rotation in 3d plot matlab") - I don't have matlab today to try that one... But I am not sure if it can even work with my problem.
origin = [13 58]
If you want some details about the contexte of this problem, here it is:
I am currently working in engineering and I have to do some experiments. In these experiments, I have to take two pictures of a burner: one with the burner cold and a graduated metal rod in it to make the mire (although I don't know if the term exist in english), the other picture is of the burner functionning. The mire help me to transform the image in matlab and know the distances, then I apply the same transformation in the second picture and I can have the flame length simply by mesuring from a point to another.To simplify the operation, I want the origin at the exit of the burner, so that I have directly the distance from the exit when I select a point on the flame. If I am not clear enough, let me know, please.
Thank you for your time and patience
E.L.
Accepted Answer
More Answers (2)
I was trying to do this the other day. I could not find anything, so I just manually shifted all of my data points. Let's say you have
x = [1 2 3 4];
y = [5 6 7 8];
and you want (1,5) to be the origin. Then just do
x = x - 1;
y = y - 5;

Above is an image of the original points on the left, and the points shifted so that (2,6) is the origin on the right.
4 Comments
Elisa Lafforgue
on 26 Jun 2018
Image Analyst
on 26 Jun 2018
I thought you said "Lets say I have an image named "image"" not a plot. Anyway, the concept Mark showed you of subtracting the offset can work with an image too. If you don't like reading the actual shifted (x,y) point directly off the image like I showed you, you can just get the coordinate by whatever means, like impixel() or impixel() or ginput(), and subtract the offset in code to get the shifted/recentered version.
Mark Saad
on 26 Jun 2018
I used the scatter function to plot the points alone.
% Set initial points.
x = [1 2 3 4];
y = [5 6 7 8];
% Plot initial points
subplot(1,2,1);
scatter(x,y,'r');
% Shift the points
x = x - 1;
y = y - 5;
% Plot the shifted points
subplot(1,2,2);
scatter(x,y,'b');
Elisa Lafforgue
on 27 Jun 2018
Categories
Find more on Blue in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!