# Shift the origin (0,0) of the pixels in my image

101 views (last 30 days)
Aude Rapet on 1 Feb 2017
Answered: wenjie liu on 5 Dec 2019
Hi,
As an input of my code, I need to have some positions on my picture: the positions are in pixels and the origin (0,0) is in the CORNER top left of my picture
The problem is that when I run my code which maps the positions on my picture, the origin shifts to the bottom left :
So my question is : how could I also shift my input (positions of my picture1) so that it is relevant with the code process?
Thank you for your help, Aude

Walter Roberson on 1 Feb 2017
set(gca, 'ydir', 'reverse')

Aude Rapet on 2 Feb 2017
I read the documentation about set but I am not quite sure about how to use it. Should I apply it once I have the list of the y- positions? If my y- positions are the 2nd column of a matrix a, should I use it this way :
set(a, 'a(:,2)', 'reverse');
I had the error message : Error using handle.handle/set Invalid or deleted object.
Image Analyst on 2 Feb 2017
No. Just put his line of code, exactly as it is , right after you call imshow(). The badly-named "a" (y values) is not used at all in the call to set().
Aude Rapet on 2 Feb 2017
Thank you Image Analyst for your comment, it is working perfectly!

Camille Marin on 13 Apr 2018
Edited: Camille Marin on 20 Apr 2018
Hello all,
With the same spirit, is it possible to assign specific coordinates to the image's origin in order to use them for an imwarp function ? For instance, I would like to click on my image via the "ginput" function, and I want to assign the X,Y values to the image origin, instead of having it at the top left (1,1).
close all
clearvars
%Declaration of the polynomial (4 degree) vectors A & B. Only A has values,
since no modification ocured on the Y axe
A_tot=[- 1.5828, 0.8289, 0, 0,0.0007, 0,0, 0, - 1E-06, 0,0,0,0,3E-10,0];
B=zeros(1,15);
B(3)=1;
tform = images.geotrans.PolynomialTransformation2D(A_tot,B);
xWorldLimits = [-121 647];
yWorldLimits = [-528 240];
RA = imref2d(size(Mire_def),xWorldLimits,yWorldLimits);
Mire_corr=imwarp(Mire_def,RA,tform)