Convert color to value
11 次查看(过去 30 天)
显示 更早的评论
Hello everyone. I have a jpg image with blue to red color corresponding to different value. There is also a colorbar showing each colorscale correspond to a value. Is there a simple way to convert this color image into matrix? Thanks a lot.
0 个评论
采纳的回答
Jos (10584)
2017-11-30
So you have combinations of red and blue colour values (R,B) that correspond to a some arbitrary single values V according to the colour scale. Perhaps 2D interpolation, will work for you:
Extract all the the (R,B) combinations for each pixel (Rq,Bq)
Vq = interp2(R,B,V,Rq,Bq)
If the green channel is also important, use interp3.
0 个评论
更多回答(2 个)
Image Analyst
2017-11-30
See my attached demo where I used the colormap in a thermal image to convert that into a grayscale temperature image.
0 个评论
Stephen23
2017-11-30
2 个评论
Image Analyst
2017-11-30
That's the gist of it, but it's not that simple unless you already have the colormap. In many cases, the user does not and has only some kind of screenshot. My solution also uses rgb2ind() but also does the hard part of figuring out how to obtain the colormap.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Blue 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!