% Draw a frame on the edge of a grayscale image

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);
for r = 1:nr
for c = 1:nc
if (r <= width) || (r > nr - width) || ...
(c <= width) || (c > nc - width)
P(r,c)= frameColor;
end
end
end

imshow(P)