Image changing to blue and yellow?

6 ビュー (過去 30 日間)
Chris Gnam
Chris Gnam 2017 年 9 月 25 日
コメント済み: Jan 2017 年 9 月 26 日
I'm trying to render the moon in orbit around the Earth. I was able to get a decent map of the Moon, which I then want to wrap over a sphere. (This is the same process I did for the Earth, and it turned out perfectly). The only problem is, when I try to do that with the moon image, it changes all the colors around and suddenly becomes blue and yellow.
Here, I've included on the left hand side, the 3d model, and on the right hand side, the image itself.
I'm really at a loss as to why this would be happening... Here is my code if that is useful:
[x,y,z] = sphere(120);
Xmoon = RenderedLunarRadius*x;
Ymoon = RenderedLunarRadius*y;
Zmoon = RenderedLunarRadius*z;
Moon = imread('Moon Texture.jpg');
Moon = flip(Moon ,1);
Moon = surface(Xmoon + 2*Re,Ymoon,Zmoon, Moon,...
'FaceColor','texturemap','EdgeColor','none');
alpha(Moon,1);
material(Moon,'dull')
  1 件のコメント
Stephen23
Stephen23 2017 年 9 月 25 日
Change the colormap.

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2017 年 9 月 25 日
Your image of the moon is treated as indexed color image and the current colormap is applied. Convert it to an RGB image instead:
[Moon, Map] = imread('Moon Texture.jpg');
if ~isempty(Map)
MoonRGB = ind2rgb(Moon, Map);
else
MoonRGB = im2double(Moon);
end
Does it work? Perhaps a double(Moon) / 255 is useful also.
  2 件のコメント
Chris Gnam
Chris Gnam 2017 年 9 月 25 日
Neither of those seem to fix the problem.
The only other thing that I've noticed is that the behavior can be replicated if I display the image using imagesc(), it then displays a 2d image with the same yellow/blue color scheme.
I tried setting CDataMapping,'direct', instead of the default, but this did not work either.
Do you have any other suggestions as to what might work?
Jan
Jan 2017 年 9 月 26 日
Give us a chance to test, what we suggest: Attach the image file. The solution will be trivial, but currently I need to guess.
Does this help:
MoonRGB = MoonRGB(:, :, ones(1,3));

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeYellow についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by