How to visualise data value with x-y coordinate in an image
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, suppose I have x-y coordinate and z value as the grades of the points. How can I visualize my data in 2-D colormap ? (I want to show x-y cordinate and different colors for different values at every points inside the image). I am attachng sample data text file and regarding image.
Please help.
댓글 수: 2
Walter Roberson
2019년 9월 15일
I suspect you want griddedInterpolant()
Along with a colormap such as 'hot' or perhaps 'autumn'
답변 (1개)
Image Analyst
2019년 9월 15일
Try something like
data = dlmread(filename, ' ');
x = data(:, 1);
y = data(:, 2);
grayLevel = data(:, 3);
grayImage = zeros(ceil(max(y)), ceil(max(x)));
for k = 1 : length(x)
row = round(y(k));
col = round(x(k));
grayImage(row, col) = grayLevel(k);
end
grayImage = mat2gray(grayImage);
imshow(grayImage, 'ColorMap', jet(256));
colorbar;
댓글 수: 4
Image Analyst
2019년 9월 15일
Not only the blue, but for most of them. There are 181 pixels that are not zero. But most of your image locations do not have a gray level defined for them, so they are left as zero and appear as blue.
data = dlmread('md1.txt', ' ');
x = data(:, 1);
y = data(:, 2);
grayLevel = data(:, 3);
grayImage = zeros(ceil(max(y)), ceil(max(x)));
for k = 1 : length(x)
row = max([1, round(y(k))]);
col = max([1, round(x(k))]);
grayImage(row, col) = grayLevel(k);
fprintf('Assigning %d to row %d, column %d.\n', grayLevel(k), row, col);
end
minGL = min(grayImage(:))
maxGL = max(grayImage(:))
grayImage = mat2gray(grayImage);
imshow(grayImage, [], 'ColorMap', jet(256));
colorbar;
참고 항목
카테고리
Help Center 및 File Exchange에서 Blue에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!