Drawing a color map of accuracy distribution
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi I have two matrices: one stores the indices of rectangles' locations on the screen and the other stores the accuracy information in the corresponding location.
For example:
RectMat =
155 95 189 129
223 95 257 129
291 95 325 129
359 95 393 129
427 95 461 129
495 95 529 129
Accuracy =
0.2
0.4
0.6
0.8
0.9
1.0
Now I need to plot such an accuracy distribution map: rectangles will be drawn as to match the locations and the color of the rectangles should depend on the accuracy value in that specific location, e.g. RED for 100% and BLUE for 0%.
Also, I need a color bar presented beside the figure to show how the colors represent the accuracy.
I also need it to include, at least, 11 colors (0%:10%:100%) and I can manage the color properties.
Could anyone please help me with this?
Thanks a lot!
Best, Leo
1 Kommentar
Antworten (1)
Image Analyst
am 5 Apr. 2012
Have you tried anything like this yet? You simply figure out the color for that Accuracy, and call rectangle() with the 'EdgeColor' of that particular color.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
workspace; % Make sure the workspace panel is showing.
RectMat =[...
155 95 189 129
223 95 257 129
291 95 325 129
359 95 393 129
427 95 461 129
495 95 529 129]
Accuracy = [...
0.2
0.4
0.6
0.8
0.9
1.0]
% Create some custom colormap with 11 elements, such as the jet one.
myColors = jet(11)
numberOfRectangles = size(RectMat, 1);
for r = 1 : numberOfRectangles
% Get the Accuracy for this rectangle and
% figure out the color row in the colormap for this Accuracy.
colorRow = int32(Accuracy(r) * 10);
% Plot the rectangle with that color.
rectangle('Position', RectMat(r, :), ...
'EdgeColor', myColors(colorRow,:),...
'LineWidth', 3);
end
grid on;
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
2 Kommentare
Siehe auch
Kategorien
Mehr zu Blue finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!