Image How do I convert xyz coordinates into an image?

14 ビュー (過去 30 日間)
Doyinsola Oduwole
Doyinsola Oduwole 2020 年 6 月 26 日
コメント済み: Image Analyst 2021 年 5 月 5 日
I have the xyz cordinates of a surface obtained from a focus variation microscope. I want to convert those cordinates into image form using matlab and feed into another imaging processing software.
How do I go about this? I have tried using xyz2rgb() and rgb2gray() which give me a colour map.
  2 件のコメント
KSSV
KSSV 2020 年 6 月 26 日
Okay you have tried is the problem solved?
Doyinsola Oduwole
Doyinsola Oduwole 2020 年 6 月 26 日
I think my question is, is the result of trasnforming x,y,z cordinates a color map as shown?

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2020 年 6 月 26 日
Colorimetric xyz has nothing at all to do with spatial xyz coordinates. They're entirely different things. You would definitely not use xyz2rgb().
What you want is to either just make the image from the xyz coordinates where z is a gray level
rows = ceil(max(y(:)))
columns = ceil(max(x(:)))
grayLevels = mat2gray(z(:))
grayImage = zeros(rows, columns, 'uint8')
for k = 1 : length(y)
row = ceil(x(k));
col = ceil(y(k));
grayImage(row, col) = grayLevels(k);
end
imshow(grayImage, []);
or use griddedInterpolant() or scatteredInterpolant() (demo attached).
  3 件のコメント
imran ahmed
imran ahmed 2021 年 5 月 5 日
編集済み: Image Analyst 2021 年 5 月 5 日
To solve that error.
rows = ceil(max(y(:)))
columns = ceil(max(x(:)))
grayLevels = mat2gray(z(:))
grayImage = zeros(rows, columns, 'uint8')
for k = 1 : length(y)
row = ceil(x(k));
col = ceil(y(k));
if row<1
row=1;
end
if col<1
col=1;
end
grayImage(row, col) = grayLevels(k);
end
imshow(grayImage, []);
Image Analyst
Image Analyst 2021 年 5 月 5 日
Another way would be to just specify how many rows and columns you want the image to be, and scale your x and y to go from one up to the dimension size:
rows = 1080; % HDTV
columns = 1920; % HDTV
grayLevels = mat2gray(z(:))
% Rescale x and y
% Convert scaled x and y to integers with round() because they are row and column
% indexes, which need to be integers.
x2 = round(rescale(x, 1, columns));
y2 = round(rescale(y, 1, rows));
grayImage = zeros(rows, columns, 'uint8')
for k = 1 : length(y2)
% Get the row and column for this y and x, respectively.
row = x2(k);
col = y2(k);
% Now assign the gray level at that location.
grayImage(row, col) = grayLevels(k);
end
imshow(grayImage, []);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by