From: Ibtesam Saleh on
I want to compute the maximum and minimum values in both x-axis and y-axis of my image (xmin, xmax, ymin and ymax)? I know that I should use xlim and ylim but I don't know how to use them to get these values from my image?
From: Walter Roberson on
"Ibtesam Saleh" <bossy_4me(a)yahoo.com> wrote in message <ht4d3j$r5f$1(a)fred.mathworks.com>...
> I want to compute the maximum and minimum values in both x-axis and y-axis of my image (xmin, xmax, ymin and ymax)? I know that I should use xlim and ylim but I don't know how to use them to get these values from my image?

In general, you cannot count on xlim and ylim corresponding to the min and max of your data, because xmin and ylim control what range of data is plotted, not what range of data is there. xlim and ylim will have been rounded to show "nice" plots. For example, when I used

plot(rand(1,5),rand(1,5))

then xlim was [0.2 1] and ylim was [0 1] because the random numbers for x were from .29 to .82 and the random numbers for y were from .05 to .93 . The xlim and ylim chosen by Matlab frame those values "nicely".

In the case of a single image in the figure with nothing else, then
xlimits = xlim;
ylimits = ylim;
and then the first element of xlim is a min and the second is a max.
From: Ibtesam Saleh on
I am sorry... but I am really not understood...

I want these values to crop my image
Image = imcrop (image,[ n2 , m2 , width , length ])
%m1= ymax
%m2= ymin
%Length = m1 &#8211; m2
%n1=xmax
%n2=xmin
%Width = n1 &#8211; n2

please help me to compute (ymax, ymin, xmax and xmin)
thanks in advance
Ibtesam
From: Walter Roberson on
Ibtesam Saleh wrote:
> I am sorry... but I am really not understood...
>
> I want these values to crop my image
> Image = imcrop (image,[ n2 , m2 , width , length ])
> %m1= ymax
> %m2= ymin
> %Length = m1 &#8211; m2
> %n1=xmax
> %n2=xmin
> %Width = n1 &#8211; n2
>
> please help me to compute (ymax, ymin, xmax and xmin)

You do not have a displayed image to compute the limits of. You would
have to image() or imshow() or the like before using xlim() and ylim() .
In the meantime,

xmin = 1
ymin = 1
xmax = xmin + width - 1;
ymax = ymin + length - 1;