Hey guys !
I want to move the origin of my axis at (x,y) of the non-standard coordinate space .. How do I go about it ? I know the function is axis (x,y) but nothing seems to be happening ..
I want to move the origin at (73, 941) of the image .. Got it from the the impixelinfo () ..

3 comentarios

Siddharth Mallya
Siddharth Mallya el 22 de Mzo. de 2011
Okay, so I managed to figure out what I was doing wrong. Here is the code I am using right now -->
M = size(img,1);
N = size(img,2);
axis ([73 M 941 N]);
Its still wrong because it is not recognising M and N variables -->
%
??? Error using ==> set
Bad value for axes property: 'XLim'
Values must be increasing and non-NaN.
Error in ==> axis>LocSetLimits at 210
set(ax,...
Error in ==> axis at 96
LocSetLimits(ax(j),cur_arg);
Error in ==> grid at 11
axis ([M 73 N 941]);
%
Walter Roberson
Walter Roberson el 22 de Mzo. de 2011
size(img,1) is the number of rows in img, which corresponds to the *Y* coordinate; likewise size(img,2) corresponds to the *X* coordinate.
Navodita Das
Navodita Das el 13 de Mayo de 2020
Suppose, an image contains red point in it. Can I set that red point as origin of coordinate system?

Iniciar sesión para comentar.

 Respuesta aceptada

Siddharth Mallya
Siddharth Mallya el 25 de Mzo. de 2011

0 votos

I actually did this finally. I scan the image left-to-right and top-to-bottom and stop the moment I find a different pixel than the background. Since I am using im2bw(); the background is white and the character pixel are black.
The moment I find the first black pixel, I store the pixel co-ordinates in 2 variables fr and fc. I then use these variables for further computation (i.e. constructing the grid)

5 comentarios

Walter Roberson
Walter Roberson el 25 de Mzo. de 2011
fc = find(any(Image,1),1,'first');
fr = find(any(Image,2),1,'last');
Siddharth Mallya
Siddharth Mallya el 26 de Mzo. de 2011
@Walter,
Thanks ! But the output I am getting from these statements is different from the one I am expecting. The 'for' loop is giving a close enough answer. The image dimension is 1123x794 and right now, FR = 1123 and FC = 1.
The correct answer (using the for loop) is, FR = 177 and FC = 73. What could be the problem ?
Siddharth Mallya
Siddharth Mallya el 26 de Mzo. de 2011
I am looking to spot black pixels (0 intensity) against white background (1 intensity)
Walter Roberson
Walter Roberson el 26 de Mzo. de 2011
Ah, normally 1 is the foreground. For your use,
fc = find(~all(Image,1),1,'first');
fr = find(~all(Image,2),1,'last');
Siddharth Mallya
Siddharth Mallya el 26 de Mzo. de 2011
fr1 =
Empty matrix: 0-by-1
fc1 =
Empty matrix: 1-by-0
Damn it !

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 22 de Mzo. de 2011

0 votos

Does the entire figure have to be affected, or just one axis, or a set of axis (such as used for plotyy) ?
Please indicate what exactly needs to be changed -- for example, is it okay if it just looks like the origin is there on the plot, or do you need to be able to specify other plotting locations relative to the new origin?
If you are just concerned about appearance, then you may be able to modify one of the Matlab File Exchange contributions such as axescenter or PlotAxisAtOrigin.
If you need the entire coordinate system changed then probably the easiest way I can think of would be to create a handle graphics transform that translated by the negative of the new coordinates.

5 comentarios

Siddharth Mallya
Siddharth Mallya el 22 de Mzo. de 2011
I am overlaying a grid on an image (braille recognition) .. If I start off the grid from the actual origin, the grid-character combination gets distorted.
I want to move the origin near the first the braille character. Right now I am trying out a static function and the (x,y) coordinates are (73, 941). I want the origin to be shifted here so the grid formation can begin from there.
Walter Roberson
Walter Roberson el 22 de Mzo. de 2011
Trying to solve this by shifting the axis is doomed to complicate things immensely.
For your situation, simply select only the part of the array that you want to deal with and manipulate that:
timg = img(1:941,73:end);
I am presuming here that you are using "axis image" so that the maximum y value corresponds to the bottom of the array in storage.
Siddharth Mallya
Siddharth Mallya el 22 de Mzo. de 2011
Oh would it ? Thanks for warning me ! :)
Okay, the solution you have given me does nothing. The image array remains exactly the same ?
(Btw, is there any way I could talk to you in real time ?)
Walter Roberson
Walter Roberson el 22 de Mzo. de 2011
Well, tell it to plot timg after you trim off the part you don't need.
Sorry, my timezone is GMT-5 now, so it is about quarter after one in the morning and time for me to go to bed. And I don't Skype or Google Voice.
Siddharth Mallya
Siddharth Mallya el 22 de Mzo. de 2011
Oh I meant like chat. But that's okay. Anyway, like I was saying, using img = img(1:941,73:end);
did not change anything .. (i used the same variable 'img' so I wont have to change the rest of the instances in the program)

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 22 de Mzo. de 2011

Comentada:

el 13 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by