How to overlap Jpeg images in MatLab

조회 수: 1 (최근 30일)
Thomas P
Thomas P 2015년 4월 1일
편집: Thomas P 2015년 4월 1일
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에서 Display Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by