How to overlap Jpeg images in MatLab

1 Ansicht (letzte 30 Tage)
Thomas P
Thomas P am 1 Apr. 2015
Bearbeitet: Thomas P am 1 Apr. 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.

Antworten (1)

Joep
Joep am 1 Apr. 2015
Bearbeitet: Joep am 1 Apr. 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);

Kategorien

Mehr zu Display Image finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by