thank you for your quick response!I have tried it but it returns many values for x,y whereas I want only the value where the intensity equals the maximum intensity.With the histogram I can check the bin where the maximum is.

The problem is that your code doesn't find the maximum intensity of your image but the maximum of the histogram. So max1 is the heigth of the bin and so it corresponds to the number of the most frequent intensity values.

If you want the maximum intensity the code is this:

max_int=max(Image(:))

And if you want the x y positions of the pixels with the maximum intensities:

[x y]= find(Image==max_int)

if the outputs are two vectors it means that there are more than one pixel with the maximum intensity in the image.

thank you!so if I want a line to pass through x,y where the intensity is maximum how can I write it? I have written the code below as an example and I want x to take the value of the maximum x but also be in the range 1 to 256

There is a problem. I try to explain:through the point x,y pass infinite rows. If you want to leave [b]a[/b] as a parameter, you have to force a contition to [b]b[/b], and this condition depends on the fact that the rows have to pass through the point x,y.For example, the first row has to pass to x,y and has a=50. x,y are fixed, so you have to compute b as:b = y-a*x