function purikura(input_img,output_img)
% e.g : purikura('anime1.jpg','made1.jpg');
%This function frames an image with a beautiful frame in JAPANESE PURIKURA STYLE.
%warning off
warning( 'off', 'all');
%------------------------------------------------------------------------
img=imread(input_img);
m=size(img,1);
n=size(img,2);
img1=img(1:floor(m/2),1:floor(n/2),:);
img2=img(1:floor(m/2),floor(n/2)+1:n,:);
img3=img(floor(m/2)+1:m,1:floor(n/2),:);
img4=img(floor(m/2)+1:m,floor(n/2)+1:n,:);
frame_img=imread('design.jpg');
m=size(frame_img,1);
n=size(frame_img,2);
frame_img1=frame_img(1:floor(m/2),1:floor(n/2),:);
frame_img2=frame_img(1:floor(m/2),floor(n/2)+1:n,:);
frame_img3=frame_img(floor(m/2)+1:m,1:floor(n/2),:);
frame_img4=frame_img(floor(m/2)+1:m,floor(n/2)+1:n,:);
a1=mould(frame_img1,img1);
a2=mould(frame_img2,img2);
a3=mould(frame_img3,img3);
a4=mould(frame_img4,img4);
a=[a1 a2;a3 a4];
a=uint8(a);
imwrite(a,output_img);
function frame_img=mould(frame_img,img)
% This function replaces the black pixels of an image with the corresponding pixels of an
% other image.
m1=size(img,1);
n1=size(img,2);
frame_img=imresize(frame_img,[m1 n1],'nearest');
sgn_matrix=not(sign((frame_img-15) +abs( frame_img-15)));
frame_img=double(frame_img)+double(sgn_matrix).*double(img);