Monday, July 21, 2014

Alpha Blending Matlab Code


Ibg=imread('E:\IP\codes\flower.jpg');
Ifg=imread('E:\IP\codes\beetle.jpg');

if length(size(Ibg))==3
        Ibg=rgb2gray(Ibg);
end
if length(size(Ifg))==3
        Ifg=rgb2gray(Ifg);
end

alpha = 0.2;

[row,col] = size(Ibg);
I = zeros(row,col);
I = uint8(I);
for i = 1:row
    for j = 1:col
        I(i,j) = alpha * Ibg(i,j) + (1 - alpha) * Ifg(i,j);
    end
end

subplot(1,3,1); imshow(Ibg);
subplot(1,3,2); imshow(Ifg);
subplot(1,3,3); imshow(I);