show an image as categorised

I have an image with 3 layers (R,G,B). I want to show each layer as a cateogorised image as I can define the range of values in each category. I also want to add a legend as it show the range of values and the assigned color, a map scale (in kilometer) and geographical north direction. for eaxample I want to show the layer 1 as: 0.05-0.1>>blue 0.1-0.15>>green 0.15-0.2>>yellow 0.2-0.25>>red
Could you please help me about that?

Antworten (2)

Walter Roberson
Walter Roberson am 29 Jun. 2011

0 Stimmen

Perhaps you could use contour() and supply the level list

9 Kommentare

Hassan
Hassan am 29 Jun. 2011
thanks Walter for the comment. I think contour() show the pixels with the same value as a line which is different with what I want.
Walter Roberson
Walter Roberson am 29 Jun. 2011
To turn off the lines in contour(), pass the additional parameter 'none' as the linespec argument.
Hassan
Hassan am 29 Jun. 2011
I used contour(Myimg(:,:,1),'none') but it gave me an error message (?? Error using ==> contour at 73
Error in color/linetype argument.).
Walter Roberson
Walter Roberson am 29 Jun. 2011
It appears that 'none' is a later version than you or I are using. But you can use this:
[edges,chandle] = contourf(Myimg(:,:,1));
set(chandle,'LineStyle','none');
Hassan
Hassan am 29 Jun. 2011
thanks Walter. Well, it seems the image was rotated after using this command. and I don't know how to add a legend, a map scale and the geographical north. I don't know in the resulted image each color means.
Walter Roberson
Walter Roberson am 29 Jun. 2011
[edges,chandle] = contourf(Myimg(:,:,1).', [0.1, 0.15, 0.2, 0.25]);
set(chandle,'LineStyle','none');
colorbar;
colormap([0 0 1; 0 1 0; 1 1 0; 1 0 0]);
annotation('arrow', [X1 X2],[Y1 Y2], 'HeadStyle', 'hypocycloid'); %with appropriate X and Y
I do not know if there is a good way to create a map scale with tick marks.
Hassan
Hassan am 30 Jun. 2011
thanks Walter for the code. It still doesnn't show the image in the right position as it rotated the image again.It seems it doesnt show all the pixels.
Walter Roberson
Walter Roberson am 30 Jun. 2011
Which direction does using Myimg(:,:,1) display relative to what you would like displayed?
Hassan
Hassan am 30 Jun. 2011
well in the array I want to have each pixel displayed according to its row and column.

Melden Sie sich an, um zu kommentieren.

Sean de Wolski
Sean de Wolski am 29 Jun. 2011

0 Stimmen

Perhaps you could convert it to be identical to a label image and then use label2rgb to show it?

6 Kommentare

Hassan
Hassan am 29 Jun. 2011
thanks Sean. I think label2rgb() is more useful for a classfied image while my image is not. I want to assign one color to a range of pixel values.
Sean de Wolski
Sean de Wolski am 29 Jun. 2011
Yes. So set every pixel in each range to an integer monotonically increasing from 1. label2rgb sounds like exactly what you want!
Hassan
Hassan am 29 Jun. 2011
I know if I use L = bwlabel(BW, n), it gave me a matrix with identical values. But I don't know how to tell the function to assign the identical value to a range of values.
Sean de Wolski
Sean de Wolski am 29 Jun. 2011
Use hist on each channel reshaped to a vector; get the second output (the bin); reshape all three channels back into their beginning shape; set up some criteria on which bins make what values and then label based on the values.
Show us a better set of sample data and the expected results. Perhaps a 2x2x3 matrix and the criteria used to determine "category"
Hassan
Hassan am 29 Jun. 2011
a(:,:,1) =
0.1000 0
0.0050 0.5000
a(:,:,2) =
0.1500 0.0500
0.0550 0.5500
a(:,:,3) =
0.2000 0
0.0100 1.0000
for example in the array a, I want to have 3 category like:
a(:,:,1):
0.001 to 0.005>>blue
0.006 to 0.1>>green
0.1 to 0.5>> yellow
for a(:,:,2):
0.01 to 0.05>>blue
0.06 to 0.15>>green
0.16 to 0.55>> red
and so on
Hassan
Hassan am 30 Jun. 2011
sorry Sean, I didnt underestand what I should do.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 29 Jun. 2011

Community Treasure Hunt

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

Start Hunting!

Translated by