Imagesc & plot matrix

조회 수: 5 (최근 30일)
Salvatore Turino
Salvatore Turino 2011년 12월 9일
Hello, actually i'm trying to plot a matrix. The values of this matrix are variable between -1 and 1 (i'm working on the correlation between different data). in figure:
this is a matrix 5x5 but to who has never seen the numerical matrix i think that it is difficult to understand. i want to know if exists a way to know for example what i'm correlating between the value 0.5 1.5, i mean i know what i'm correlating but i want that also the others watching this plot can understand it easy. another thing that i'ven't understood is what the numbers between 0.5 and 5.5 stay for.
pcolor can be used in this case?how?
thank you for the help
  댓글 수: 1
Image Analyst
Image Analyst 2011년 12월 9일
Explain what you mean by "i want that also the others watching this plot can understand it." I'm sure others who would view your images or plots would understand what you did especially if you explained it to them, wouldn't they?

댓글을 달려면 로그인하십시오.

채택된 답변

Sven
Sven 2011년 12월 9일
Salvatore, try this:
Im = [1.0000 0.7944 0.7361 0.8205 0.4192
0.7944 1.0000 0.8663 0.6780 0.3435
0.7361 0.8663 1.0000 0.7351 0.3311
0.8205 0.6780 0.7351 1.0000 0.3555
0.4192 0.3435 0.3311 0.3555 1.0000]
imagesc(Im)
cHandle = colorbar;
caxis([-1 1]) % This sets the visible range of colours
set(gca,'XTick',1:5,'YTick',1:5) % This sets the tick locations
You can also use different colours as seen in:
doc colormap
You can even supply your own colormap by building a matrix of N-by-3 values between 0 and 1.
The reason why your X/Y axes go from 0.5 to 5.5 is because every pixel has a size of 1 pixel. So the first pixel has a central location at [1,1]... but in order to show the whole pixel (with a width of 1 pixel), it has to start at location [0.5,05] and stretch to location [1.5,1.5]
A good explanation of this (with pictures) is at:
Doc > Image Processing Toolbox > Introduction

추가 답변 (2개)

Salvatore Turino
Salvatore Turino 2011년 12월 9일
well first of all i want a colorbar that starts from 0 and goes to 1 or bytheway from -1 to 1, this means that i want to set the interval. after that i want to understand why the X and Y axes start from 0.5 and ended to 5.5.
thank you to all
consider that my final matrix is this one:
1.0000 0.7944 0.7361 0.8205 0.4192
0.7944 1.0000 0.8663 0.6780 0.3435
0.7361 0.8663 1.0000 0.7351 0.3311
0.8205 0.6780 0.7351 1.0000 0.3555
0.4192 0.3435 0.3311 0.3555 1.0000
so for example is it possible instead to have values from 0.5 to 5.5 set for the x-y axes only the value 1 2 3 4 5?
  댓글 수: 4
Salvatore Turino
Salvatore Turino 2011년 12월 9일
ok sven i like the explanation about the X/Y values. i want to ask you if it is possible to assign by myself the colors that colorbar does automatically.
because i have different matrices and i want an uniformity of colors
Sven
Sven 2011년 12월 9일
Yes, you can. see "doc colormap" or type "lines(5)", "summer(5)" and "gray(5)" into the command window and see the output

댓글을 달려면 로그인하십시오.


Salvatore Turino
Salvatore Turino 2011년 12월 9일
i've tried to use lines/summer/gray but i don't like the effect. actually the matrix is something like this:
(that is the plot of the matrix i've posted before) if i use the command caxis the colors became more fuzzy and i don't like it...it is difficult to see the differences between the position (1,1) and for example the (2,1). This is because, for what i've understood, imagesc does an interpolation right?
well i want to know if i can set at every position of the matrix the color that i choose and if i can use this color for different values. I mean in the first matrix at position (2,1) i have as result 0.98 and i want to associate to it the color blue, in the second matrix at the position (2,1) also if i have a different value i want to associate always the color blue. is it possible?
  댓글 수: 2
Sven
Sven 2011년 12월 9일
Sure, this is called an index colour map. Note that this is a different way of representing colour to what this question originally asked. I think a good idea to keep topics separate (and therefore clear) will be to accept an answer here and ask a new question if needed.
A really good place to start will be at "doc gray2ind". It might answer this second question for you, but if not you can always start a new question on that topic.
Sven
Sven 2011년 12월 9일
And I think your best resource might be to start at:
Doc > Image Processing Toolbox > Introduction
There are two topics there "Expressing Image Locations" and "Image Types In the Toolbox" which give great examples of the pixel location question and this colour representation question.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by