% Draw a frame on the edge of a grayscale image --
% a more verbose but more efficient version

close all

% Read the original picture (PNG file) and show it:
P= imread('liftingbody.png');
imshow(P);
pause

% Add a frame 50 pixels wide on the edge of picture
width= 50;
frameColor= 20; % dark gray
[nr,nc]= size(P);
% Top and bottom bars:
for r = 1:width
for c = 1:nc
P(r,c) = frameColor;
P(nr-r+1,c)= frameColor;
end
end
% Left and right bars:
for c = 1:width
for r = (width + 1):(nr - width)
P(r,c) = frameColor;
P(r,nc-c+1)= frameColor;
end
end

imshow(P)