Image coordinates problem - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Image coordinates problem

lee_mylolee_mylo Posts: 18Member
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!

Comments

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

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

    max1=max(Image(:));
  • lee_mylolee_mylo Posts: 18Member
    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: 217Member
    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.
  • lee_mylolee_mylo Posts: 18Member
    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

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

  • giuggiug Posts: 217Member
    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: 18Member
Sign In or Register to comment.