How to overlap Jpeg images in MatLab

1 次查看(过去 30 天)
Is it possible to use multiple jpgs in Matlab using something like the transparency? I am planning on making a battleship- like game on Matlab for a project. I want to use X's on the ships. I have a picture of the ships; however, I cannot find a way to take a X jpg and use it in the foreground. Please Help! Please provide code if possible. I understand so far
imread('x.jpg') %Background image
imshow('x.jpg')
From here, I do not know how to use transparency functions nor creating another jpg on top.

回答(1 个)

Joep
Joep 2015-4-1
编辑:Joep 2015-4-1
rgb = imread('peppers.png');
imshow(rgb);
I = rgb2gray(rgb);
hold on
% Save the handle for later use
h = imshow(I);
hold off
[M,N]=size(I);
%Create matrix for transparency
alpha=zeros(M,N);
%Matrix part with transparency
alpha(1:100,1:N)=0.5;
set(h, 'AlphaData', alpha);

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by