% Draw a frame on the edge of a grayscale jpeg image

close all

% original picture
P= imread('bwduck.jpg');
imshow(P);
[nr,nc]= size(P);
pause
% Add a frame 50 pixels wide on the edge of picture
width= 50;
white= 255;
for r= 1:nr
    for c= 1:nc
        if r<=width || r>nr-width ||c<=width ||c>nc-width
            P(r,c)= white;
        end
    end
end

imshow(P)