What function other than colormap can display an image as a texture-mapped surface?
조회 수: 5 (최근 30일)
이전 댓글 표시
I already know how to wrap one image around a sphere, but once I introduce a second image into my code, I lose the first one. I believe it's because the colormap command is using the map from my second image (earth) instead of holding on to the first (sun). I've been told that trying to have multiple colormaps would be unnecessarily complicated and that there is another function that I can use instead, but I haven't been able to figure out which function I'm supposed to use.
for n = 1:numberOfPlanets
if n == 1
image = imread('sun.jpg');
else
image = imread('earth.jpg');
end
[indexed_image,map] = rgb2ind(image,256);
hold on
[x,y,z] = sphere;
planets = surf(x*Planet(n).Radius.r+Planet(n).Position.x,...
y*Planet(n).Radius.r+Planet(n).Position.y,...
z*Planet(n).Radius.r+Planet(n).Position.z,...
flipud(indexed_image),...
'FaceColor','texturemap',...
'EdgeColor','none',...
'CDataMapping','direct');
colormap (map)
hold off
end
댓글 수: 0
채택된 답변
Mike Garrity
2016년 3월 16일
In this example, you don't need colormaps at all. Just use the RGB images as the textures.
for n = 1:numberOfPlanets
if n == 1
image = imread('sun.jpg');
else
image = imread('earth.jpg');
end
hold on
[x,y,z] = sphere;
planets = surf(x*Planet(n).Radius.r+Planet(n).Position.x,...
y*Planet(n).Radius.r+Planet(n).Position.y,...
z*Planet(n).Radius.r+Planet(n).Position.z,...
flipud(image),...
'FaceColor','texturemap',...
'EdgeColor','none');
hold off
end
Is that because this has been overly simplified, or is your original code starting with RGB images?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Earth and Planetary Science에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!