Effacer les filtres
Effacer les filtres

Plotting colour map of changing intensities in x-y plane?

8 vues (au cours des 30 derniers jours)
mfas
mfas le 4 Juil 2015
I have a Nx3 matrix with its columns corresponding to x-coordinate, y-coordinate and intensity respectively. How do I plot a colour map of these intensities at each ones particular position in the x-y plane (with the colour representing the intensity)?

Réponses (1)

Image Analyst
Image Analyst le 4 Juil 2015
Scale the array and assign to an image and apply a colormap. Try this.
% Make an image of the points, then apply a colormap
xyv = randi(255, 10000,3);
x = xyv(:, 1); % Extract x value
y = xyv(:, 2); % Extract y value
v = xyv(:, 3); % Extract intensity value
minX = min(x);
maxX = max(x);
minY = min(y);
maxY = max(y);
minV = min(v);
maxV = max(v);
% Make image be 500 by 700
rows = 500;
columns = 700;
grayImage = zeros(rows, columns, 'uint8');
for k = 1 : length(x)
row = ceil((y(k) - minY) * rows / (maxY - minY));
column = ceil((x(k) - minX) * columns / (maxX - minX));
if (row == 0)
row = 1;
end
if (column == 0)
column = 1;
end
grayImage(row, column) = uint8(255 * (v(k) - minV) / (maxV - minV));
end
imshow(grayImage);
colorbar;
% Colormap is not gray scale.
% Apply some other colormap if you want
colormap(jet(256));

Catégories

En savoir plus sur Blue dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by