MATLAB Answers

plotting pixel values on a 256x256 image when only some pixel co-ordinates are known, and the unknowns can be 0 or NaN

1 view (last 30 days)
cgenes on 7 Aug 2018
Commented: cgenes on 8 Aug 2018
I have the indices (x,y co-ordinates) and pixel values i want to visualise on a 256x256 image (i don't have all the pixel co-ordinates, so the "missing pixels" I just want displayed as 0 or Na
my data is uploaded and is 3 columns X co-ordinate, Y coordinate and pixel value in the 3rd column
sorry stupid question but how do I do this?

Accepted Answer

Image Analyst
Image Analyst on 7 Aug 2018
This works:
s = load('XYpixelvalue.mat')
x = int32(s.dataXYZ(:, 1));
y = int32(s.dataXYZ(:, 2));
grayLevels = uint8(s.dataXYZ(:, 1));
grayImage = zeros(max(y), max(x), 'uint8');
for k = 1 : length(x);
grayImage(y(k), x(k)) = grayLevels(k);
axis('on', 'image');

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!