Image changing to blue and yellow?
6 次查看(过去 30 天)
显示 更早的评论
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 个)
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 个评论
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 Exchange 中查找有关 Yellow 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!