Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Set a colour to a value in image processing
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Image Analyst
le 13 Nov 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 commentaires
Image Analyst
le 14 Nov 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.
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!