Question

i have more than 3 binary images extracted from satellite images, that shows different classes (e.g. pixels with value 1 is water and 0 non-water and it is true for other classes like soil etc ). i wonder is there any way to show this classes in one figure. i know with 3 classes we can use 'imshow' or 'image' but what about more than 3 classes. my code is simply something like this :

a=rand(4,4,4);
b1=(a(:,:,1)<=0.5);
b2=(a(:,:,2)<=0.5); 
b3=(a(:,:,3)<=0.5);
b4=(a(:,:,4)<=0.5);

now how could i show b1 with red, b2 with green and so on in just one figure??

many many thanks for your help

Was it helpful?

Solution

For 4 binary images, you have totally 2^4 = 16 possible "colors" per pixel according to it being "water"/"soil" or a combination of these classes (if it is possible in your system).

Thus you can convert b1...b4 to a single image:

>> l = b1 + 2*b2 + 4*b3 + 8*b4; 
>> imshow( l ); colormap( rand(16,3) ); % random color map
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top