Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Set a colour to a value in image processing

1 visualización (últimos 30 días)
Ahmed Alsaadi
Ahmed Alsaadi el 13 de Nov. de 2015
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I have a color map, which is attached, has 7 regions (A_1, A_2, A_3, B_1, B_2, C_1 and C_2). The locations of these regions are fixed on the map (x and y are constant). Also I have values (numbers) ,which represent other variables for these regions, that are
C_2 1
C_1 0.49534
B_2 0.35648
B_1 0.35444
A_3 0.20162
A_2 0.09704
A_1 0.09481
I want to represent these number as colours on the map. Let's say C_2 is the highest so it can be represented in red colour while C_1 should be represented by another colour depending on its value and so on so forth. These numbers can change from run to another and that should be represented on the map as changes in the colours only not locations.
  6 comentarios
Ahmed Alsaadi
Ahmed Alsaadi el 13 de Nov. de 2015
Any help is appreciated
Image Analyst
Image Analyst el 13 de Nov. de 2015
Would you like some help? I'm not sure.

Respuestas (2)

Image Analyst
Image Analyst el 13 de Nov. de 2015
Just create a colormap with 8 colors - the 7 you want plus white for "the background". Then apply it.
C_2 = 1
C_1 = 0.49534
B_2 = 0.35648
B_1 = 0.35444
A_3 = 0.20162
A_2 = 0.09704
A_1 = 0.09481
indexedImage(1:30,1:30) = C_2;
indexedImage(1:30,31:60) = C_1;
indexedImage(1:30,61:90) = B_2;
indexedImage(31:60,1:30) = B_1;
indexedImage(31:60,31:60) = C_2;
indexedImage(31:60,61:90) = A_3;
indexedImage(61:90,1:30) = A_2;
indexedImage(61:90,31:60) = A_1;
imshow(indexedImage, [], 'InitialMagnification', 800);
axis on;
colormap(jet(256));
colorbar;
Your numbers are not equally spaced and so some have very similar colors. You might have to do precision surgery on your colormap to make it how you like, but honestly, it might be better to just create an RGB image with known colors.
  4 comentarios
Ahmed Alsaadi
Ahmed Alsaadi el 13 de Nov. de 2015
Each run has its own values(only values in the array will change, that are A_1, A_2, A_3, ... and C_2, after each run), then ONLY colours of C_1, C_2, etc on the map should be changed since the colours should be combined with the values.While C_1, C_2, etc must stay in the same location.
I would rather to have different colours for different areas I used red colour as an example to refer to the max value, if we comeback to the same example above which is
C_2 = 1 (red) C_1 = 0.49534 (Yellow) B_2 = 0.35648 (Blue) B_1 = 0.35444 (Magenta) A_3 = 0.20162 (Cyan) A_2 = 0.09704 (Green) A_1 = 0.09481 (Black)
As we can see in the example above C_2 should be represented in a red colour on the map and C_1 should be yellow, so on so forth.
BUT
In the next run A_1 might be the max value so it is going to be red and it should be represented in the red colour on the map and the same for the rest of the array.
In all cases my image is divided into sections that are A_1, A_2 .... C_2. These must be fixed in their places unless I won't be able to recognise which section is which
Image Analyst
Image Analyst el 14 de Nov. de 2015
Sorry - I'm not following. Why don't you just make up an RGB image with squares of the colors you want? It's not that hard. Anyway, good luck.

Ahmed Alsaadi
Ahmed Alsaadi el 14 de Nov. de 2015
Sorted,
Thank you very much for the valuable info.
Ahmed,

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by