
plotting pixel values on a 256x256 image when only some pixel co-ordinates are known, and the unknowns can be 0 or NaN
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Image Analyst
2018년 8월 7일
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
Image Analyst
2018년 8월 7일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!