Changing Color based on intensity value ???
Show older comments
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 Comments
Image Analyst
on 17 Mar 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
on 17 Mar 2013
sathish kumar rb
on 22 Aug 2017
how to superimpose the intensity values of the lung tissues from the original input slice.(after the lung background removal)
Image Analyst
on 22 Aug 2017
What does that mean? You mean like you want to use text() to superimpose the gray level over a pixel?
sathish kumar rb
on 24 Sep 2017
Edited: Walter Roberson
on 24 Sep 2017
- noise removed and edge enhanced
- optimal thresholding based segmentation(out:binary image)
- cavity filling(out:binary image with background)
- background removal
in this final step background removal i need to do some steps. they are
- Fill the black pixels representing lung regions with the intensity values of the neighboring white pixels.
- Find all the 8-connected components and compute the area of each component.
- 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.
- Superimpose the intensity values of the lung tissues from the original input slice.
Walter Roberson
on 24 Sep 2017
Edited: Walter Roberson
on 24 Sep 2017
Wouldn't it make more sense to have posted that in your question about automatic ROI selection?
Image Analyst
on 24 Sep 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).
Accepted Answer
More Answers (2)
Image Analyst
on 17 Mar 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 Comments
Jujhar Khurana
on 17 Mar 2013
Image Analyst
on 17 Mar 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
on 17 Mar 2013
Image Analyst
on 17 Mar 2013
Then my code would have worked with this change:
theIntensity = z(k);
shruti
on 23 May 2013
0 votes
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 Comments
Image Analyst
on 23 May 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
on 24 Sep 2017
Edited: sathish kumar rb
on 24 Sep 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
on 24 Sep 2017
Categories
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!