Changing Color based on intensity value ???

I have a long list of two coordinates (x1 y1)(x2 y2) plus an intensity value ( a number ) associated with this set of coordinates. And I need to plot a 2D line between two coordinates of each set having color based on the intensity value. I need to plot more than say, 100 lines on a plot with color varied based on intensity value.
I have tried plot(), line() but changing color is giving me hard time ?
Can somebody suggest me a way ?

7 comentarios

Image Analyst
Image Analyst el 17 de Mzo. de 2013
The intensity value where? At (x1,y1) or (x2,y2)? Where did you get the "intensity value ( a number ) associated with this set of coordinates"? Did you get it from the image at location x1,y1 or x2,y2, or from some other way? Is that intensity value in a third array? Or do I get it directly from the image at point 1 or point 2?
Jujhar Khurana
Jujhar Khurana el 17 de Mzo. de 2013
the intensity value is for the line between (x1,y1) and (x2,y2) and we get it from a different source.
sathish kumar rb
sathish kumar rb el 22 de Ag. de 2017
how to superimpose the intensity values of the lung tissues from the original input slice.(after the lung background removal)
Image Analyst
Image Analyst el 22 de Ag. de 2017
What does that mean? You mean like you want to use text() to superimpose the gray level over a pixel?
sathish kumar rb
sathish kumar rb el 24 de Sept. de 2017
Editada: Walter Roberson el 24 de Sept. de 2017
  1. noise removed and edge enhanced
  2. optimal thresholding based segmentation(out:binary image)
  3. cavity filling(out:binary image with background)
  4. background removal
in this final step background removal i need to do some steps. they are
  1. Fill the black pixels representing lung regions with the intensity values of the neighboring white pixels.
  2. Find all the 8-connected components and compute the area of each component.
  3. Remove all the connected components lesser than a specified size using morphological operations from the image and add its complement image with the input image to this process. In this work, the size is set to 1000 pixels.
  4. Superimpose the intensity values of the lung tissues from the original input slice.
Walter Roberson
Walter Roberson el 24 de Sept. de 2017
Editada: Walter Roberson el 24 de Sept. de 2017
Wouldn't it make more sense to have posted that in your question about automatic ROI selection?
Image Analyst
Image Analyst el 24 de Sept. de 2017
Agreed, this should have all been laid out right at the start. However, this looks like more than a few minutes work, so I'm not going to write it for you, but good luck with it. Post the code if you have any trouble with any part of it. Also post any error messages that you see (ALL the red text).

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 17 de Mzo. de 2013

0 votos

There is also a FEX contribution that can handle it, if I recall.

1 comentario

Jujhar Khurana
Jujhar Khurana el 17 de Mzo. de 2013
Thank you so much Walter. I have the same rebound question what Cliff asked on the above http://www.mathworks.co.uk/matlabcentral/answers/64945-color-contours-along-a-line link that how to change LineWidth in this case as it does not work the normal way.

Iniciar sesión para comentar.

Más respuestas (2)

Image Analyst
Image Analyst el 17 de Mzo. de 2013
Make up your look up table (colormap) as a 256 by 3 array where the row index is the intensity and the columns are the color you want. For example
myColorMap = jet(256);
Then plot your lines in the overlay (untested):
for k = 1 : size(xy,1)
% Get the two coordinates.
x1 = xy1(k, 1);
y1 = xy1(k, 2);
x2 = xy2(k, 1);
y2 = xy2(k, 2);
% Get the intensity of the image at x1,y1.
theIntensity = yourImage(y1, x1); % Note row,column = y,x, not x,y.
% figure out the color from that intensity.
theLineColor = myColorMap(theIntensity, :);
% Draw a line in the overlay.
line([x1 x2], [y1 y2], 'Color', theLineColor);
end

4 comentarios

Jujhar Khurana
Jujhar Khurana el 17 de Mzo. de 2013
Hey Thank you so much for the answer. but the intensity value is same for the whole line between (x1,y1) and (x2,y2). So is this code going to work. actually, I did not get it completely how you did it.
Image Analyst
Image Analyst el 17 de Mzo. de 2013
Because of the way you explained the question, it was not clear to me that you wanted the line to change color as it went from one point to the other. I assumed that the line was going to be one single color all the way along the line. You said "having color based on the intensity value" and that's why I asked a lot of follow up questions about exactly that intensity value you were talking about. Perhaps a clearer way to state it would have been "having color based on the intensity value of the image under the line at each point under the line" (if that is even what you meant - I'm still not sure).
Jujhar Khurana
Jujhar Khurana el 17 de Mzo. de 2013
Ok Image Analyst, I will try to be more clearer next time. In this case, the intensity value for the whole line between (x1 y1) adn (x2 y2) is say, z. and for other lines, like between (x3 y3) adn (x4 y4) is z1...
Anyways, thanks.
Then my code would have worked with this change:
theIntensity = z(k);

Iniciar sesión para comentar.

shruti
shruti el 23 de Mayo de 2013

0 votos

As the above u told we can do for line..but how can we apply color intensity to the each regions of the image to identify foreground object and background object. please reply me...

3 comentarios

Image Analyst
Image Analyst el 23 de Mayo de 2013
See my answer to a similar question: http://www.mathworks.com/matlabcentral/answers/76541#answer_86216 . If you still have questions, start your own discussion since your response here is not an additional answer to Jujhar's original question.
sathish kumar rb
sathish kumar rb el 24 de Sept. de 2017
Editada: sathish kumar rb el 24 de Sept. de 2017
I HAVE DONE THIS PREPROCESSING PROCESS BASED ON THAT ATTACHED TXT FILE . CHECK MY CODE IS RIGHT R WRONG HELP TO FINISH THIS.
Image Analyst
Image Analyst el 24 de Sept. de 2017
I have answered this in your new question here.

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 17 de Mzo. de 2013

Comentada:

el 24 de Sept. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by