필터 지우기
필터 지우기

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

조회 수: 8 (최근 30일)
mfas
mfas 2015년 7월 4일
답변: Image Analyst 2015년 7월 4일
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)?

답변 (1개)

Image Analyst
Image Analyst 2015년 7월 4일
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));

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by