MATLAB Answers

0

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

Asked by Aude Rapet on 1 Feb 2017
Latest activity Answered by wenjie liu on 5 Dec 2019 at 2:01
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

  0 Comments

Sign in to comment.

3 Answers

Answer by Walter Roberson
on 1 Feb 2017
 Accepted Answer

set(gca, 'ydir', 'reverse')

  3 Comments

Thank you Walter for your reply!
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.
Thank you for your help
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().
Thank you Image Analyst for your comment, it is working perfectly!

Sign in to comment.


Answer by Camille Marin on 13 Apr 2018
Edited by 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
Mire_def= imread ('Couronne_cylindrique_cylindrique_reelle.tif');
%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)

  0 Comments

Sign in to comment.


Answer by wenjie liu on 5 Dec 2019 at 2:01

will you be able to share code on this? I found usage of finding displacement between two images as well. Thank you.

  0 Comments

Sign in to comment.