Finding Height Using Color Spectrum

5 次查看(过去 30 天)
I have an image, where the colors correspond to height. Please refer to below image. On the colormap spectrum: Blue is -500 meters Red is +500 meters
1) I want to Make plot for the height along Line 1
2) Make plot for the height along Line 2
3). Create a 2D array for the height values for the image. Basically, for every pixel position, give a corresponding height value. For simplicity, you can assume the grey pixels have a value of -1000 m.
Your help will be much appreciated.
Thanks in advance.
  12 个评论
Adnan Khan
Adnan Khan 2021-3-16
Accept answer tab is not appearing here. I want to accept the procedure you told because it worked. Thanks once again.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2021-3-17
(Moving down from comments)
timg = permute([1 0 0; 0 0 1], [3 1 2])
timg =
timg(:,:,1) = 1 0 timg(:,:,2) = 0 0 timg(:,:,3) = 0 1
image(timg)
thsv = rgb2hsv(timg)
thsv =
thsv(:,:,1) = 0 0.6667 thsv(:,:,2) = 1 1 thsv(:,:,3) = 1 1
thue = thsv(:,:,1)
thue = 1×2
0 0.6667
Pure red has a hue of 0. Pure blue has a hue of 2/3.
Pure red corresponds to a height of +500 meters. Pure blue corresponds to a height of -500 meters.
A*0 + B = 500
A*2/3 + B = -500
Subtract. 2*A/3 + (B-B) = -500 - 500 --> 2*A/3 = -1000 --> 2*A = -3000 -> A = -3000/2 --> A = -1500.
You should be able to work out B easily from this, and from that you should easily be able to calculate the formula that maps hue to height in your system.
Remember, Hue is the first pane of an HSV image, not all of the panes.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Blue 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by