Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Image coordinates problem

lee_mylolee_mylo Posts: 18
Hi to all!

I have written these lines to calculate the maximum intensity of an image from the histogram h

i = find(h);
iend = i(end);
max1 = max(h(50:iend));

How can I calculate the x,y of the image where the intensity equals the maximum intensity?

Thank you in advance!


  • giuggiug Posts: 217
    [x y]=find(Image==max1);

    But... why do you search the maximum intensity form the histogram and not directly from the image? Like:

  • lee_mylolee_mylo Posts: 18
    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.
  • giuggiug Posts: 217
    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:


    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.
  • lee_mylolee_mylo Posts: 18
    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

    for a = -50:50
    for x = ?
    y(a,x) = a*x + b

  • giuggiug Posts: 217
    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

    THEN you can find the line whith x=1:256.

    Do you understand?
  • lee_mylolee_mylo Posts: 18
    yes thank you!
Sign In or Register to comment.