![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189414/image.png)
How to set custom origin point?
52 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
Image Analyst
2018 年 6 月 22 日
Try this:
grayImage = imread('cameraman.tif');
[rows, columns, numberOfColorChannels] = size(grayImage);
origin = [13, 58]; % Assume x, y, NOT row, column
xdata = -origin(1) : columns - origin(1);
ydata = -origin(2) : columns - origin(2);
imshow(grayImage, 'XData', xdata, 'YData', ydata);
axis on;
hp = impixelinfo
grid on;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189414/image.png)
2 件のコメント
Phong
2023 年 5 月 28 日
% I'm Nguyen Tien Phong, Hung Yen University of Technical Education
%This is an application program to plot multiple graphs on the same axes
%You guys edit it to be beautiful and suitable for multi-paragraph math problems
%Ngtienphong126@gmail.com
%Good luck
clear all
syms z
y1=3*z^3+2 % Ve tu 0 den 10 Plot this graph from 0 to 10; starting position is 0
y2=3*z^4+2*z^2+6 % Ve tu 10 den 25 (0-10-10-15) Plot this graph from 0 to 15; starting position is 10
L1=10
L2=15
Xtong=linspace(0,L1+L2,20) % Chia thanh 20 doan boi 20 diem de cbi ve cho tat ca
Yt=zeros(1,20)% Tao ra de ve cac diem chia tren z cua tat ca cac doan i
X2=linspace(0,L1,100); % Chia doan 1 thanh 100 diem de ve do thi cho doan 1
A2=subs(y1,z,X2) % Nhan gia tri tai 100 diem de ve do thi cho doan 1
plot(Xtong,Yt,'Linewidth',1) % X tong la tong chieu dai de xac dinh chieu dai truc Z khi ve
hold on
plot(X2,A2,'g','Linewidth',4) % Do thi doan 1
Xve2=linspace(10,25,100); % Chia thanh 100 diem cho doan i=2 tro di
XXX2=linspace(0,L2,100)
B2=subs( y2,z,XXX2) % Nhan 100 gia tri de ve duong do thi
plot(Xve2,B2,'r','Linewidth',4); % Ve do thi
xlabel('Duong truc Z');
title(['Bieu do Nz ', ': kN'])
その他の回答 (2 件)
Mark Saad
2018 年 6 月 22 日
編集済み: Mark Saad
2018 年 6 月 22 日
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;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189415/image.png)
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 件のコメント
Mark Saad
2018 年 6 月 26 日
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');
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!