Image changing to blue and yellow?

5 views (last 30 days)
Chris Gnam
Chris Gnam on 25 Sep 2017
Commented: Jan on 26 Sep 2017
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')

Answers (1)

Jan
Jan on 25 Sep 2017
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 Comments
Chris Gnam
Chris Gnam on 25 Sep 2017
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 on 26 Sep 2017
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));

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!