![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177607/image.jpeg)
Plotting colour map of changing intensities in x-y plane?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Image Analyst
am 4 Jul. 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 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!