![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177607/image.jpeg)
Plotting colour map of changing intensities in x-y plane?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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)?
0 comentarios
Respuestas (1)
Image Analyst
el 4 de Jul. de 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));
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177607/image.jpeg)
0 comentarios
Ver también
Categorías
Más información sobre Blue en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!