Image changing to blue and yellow?
15 views (last 30 days)
Show older comments
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167497/image.png)
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
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
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));
See Also
Categories
Find more on Yellow in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!