Code covered by the BSD License  

Highlights from
FRAME MAKER + ADAPTIVE FRAMING

image thumbnail
from FRAME MAKER + ADAPTIVE FRAMING by Divakar Roy
Use your own images to make picture frames

adpframe
function adpframe

%ADPFRAME Make picture frames and then frame image.
%   Some patterns are provided alogwith this function, which can be used 
%   to make picture frames, or one can use any of one's own image of any size 
%   for making picture frames. 
warning off
%------------------------------------------------------------------------
[FileName,PathName] = uigetfile('*.jpg','Select any image on which framing is to be done');
y= [PathName,FileName];
img=imread(y);
[p q r]=size(img);

[FileName,PathName] = uigetfile('*.jpg','Select any image/pattern to be used for making picture frame');
y= [PathName,FileName];
bor=imread(y);
[m n dim]=size(bor);
if(r==1&&dim==3)
    bor=rgb2gray(bor);
end
if(r==3&&dim==1)
    error('The image/pattern must be rgb one, beacuse the image to be framed is rgb');
end

for(k=1:dim)
bor2(:,:,k)=imresize(bor(:,:,k),[floor(m*floor(q/6)/n) floor(q/6)],'nearest');
end

bor2=double(bor2);
bor=bor2;
[m n dim]=size(bor);
%------------------------------------------------------------------------
len=p;
wid=q;
slice=[n m];

m=wid-floor(wid/slice(1))*slice(1);
n=len-floor(len/slice(2))*slice(2);

m=slice(1)-m;
n=slice(2)-n;

a1=floor(m/2);
b1=m-a1;
a2=floor(n/2);
b2=n-a2;
row_des=p+a2+b2;
col_des=q+a1+b1;
image=imresize(img,[row_des col_des],'nearest');
[m n q]=size(image);
%------------------------------------------------------------------------
% image ready for bordering
m=m/slice(2);
n=n/slice(1);
[p q r]=size(bor);
base=[];
for(i=1:n)
    base=[base bor];
end
side=[];
for(i=1:m)
    side=[side;bor];
end
last=[bor base bor;side image side;bor base bor];
%------------------------------------------------------------------------
[p1 q1 r1]=size(last);
[p q r]=size(img);
[p2 q2 r2]=size(image);
last2=imresize(last,[floor(p1*p/p2) floor(q1*q/q2)],'nearest');
%------------------------------------------------------------------------
[FileName,PathName] = uiputfile('*.jpg','Give any name for the framed image');
y1= [PathName,FileName '.jpg'];
imwrite(last2,y1);
figure,imshow(last2)
%------------------------------------------------------------------------

Contact us at files@mathworks.com