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)
Show older comments
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?
thanks
0 Comments
Accepted Answer
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);
end
imshow(grayImage);
axis('on', 'image');
3 Comments
Image Analyst
on 7 Aug 2018
The original pixel values are in the range 1-255, NOT 1-6. Check your mat file again. You can leave them as double if you want, but you'll have to use [] in imshow() to see them and you'll have to set up a colormap if you want that to be an indexed image.
More Answers (0)
See Also
Categories
Find more on Red in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!