after applying you code nothing happens in image
if true
%
A = imread('shuttle.jpg');
%// Some pre-processing. Treshold image and dilate it.
B = im2bw(A,.85);
%// Detect edges
F = edge(B,'Canny');
% F=~F;
figure;
imshow(F);
hold on;
[B,L] = bwboundaries(F, 'noholes');
x = boundary(:,2);
y = boundary(:,1);
x1 = min(x);
x2 = max(x);
y1 = min(y);
y2 = max(y);
xBox = [x1, x2, x2, x1, x1];
yBox = [y1, y1, y2, y2, y1];
% Plot boundary
plot(x, y, 'm-', 'LineWidth' ,2);
% Plot bounding box.
figure;
imshow(F);
hold on;
plot(xBox, yBox, 'y-', 'LineWidth' ,2);
end