Convert color to value

9 visualizaciones (últimos 30 días)
Xin
Xin el 30 de Nov. de 2017
Comentada: Image Analyst el 30 de Nov. de 2017
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.

Respuesta aceptada

Jos (10584)
Jos (10584) el 30 de Nov. de 2017
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.

Más respuestas (2)

Image Analyst
Image Analyst el 30 de Nov. de 2017
See my attached demo where I used the colormap in a thermal image to convert that into a grayscale temperature image.

Stephen23
Stephen23 el 30 de Nov. de 2017
Use rgb2ind.
  2 comentarios
Jos (10584)
Jos (10584) el 30 de Nov. de 2017
+1 Hopefully it is indeed that simple ...
Image Analyst
Image Analyst el 30 de Nov. de 2017
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Blue en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by