What function other than colormap can display an image as a texture-mapped surface?
3 ビュー (過去 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!