How to overlap Jpeg images in MatLab

1 vue (au cours des 30 derniers jours)
Thomas P
Thomas P le 1 Avr 2015
Modifié(e) : Thomas P le 1 Avr 2015
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.

Réponses (1)

Joep
Joep le 1 Avr 2015
Modifié(e) : Joep le 1 Avr 2015
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);

Catégories

En savoir plus sur Display Image dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by