Checks are (usually) some light pastel color. Sometimes they'll have a helpful dark border, but other times (like this case, they'll be partially white. Imaging the object against an similarly-colored background is setting yourself up for problems. I know you didn't design the flatbed scanner to be that color, but it can be changed, and there are good reasons for changing it.
First, let's try to do this the hard way.
inpict = imread('check.jpg');
outpict = im2gray(inpict);
outpict = imbothat(outpict,ones(11));
[~,idx] = max(max(R,[],1));
outpict = imrotate(outpict,angle,'bilinear');
mask = bwareafilt(mask,1);
S = regionprops(mask,'boundingbox');
imshow(mask,'border','tight')
outpict = imcrop(outpict,S.BoundingBox);
imshow(outpict,'border','tight')
outpict = imrotate(inpict,angle,'bilinear');
outpict = imcrop(outpict,S.BoundingBox);
imshow(outpict,'border','tight')
On the other hand, let's say you stuck a sheet of black craft paper, felt, or PVA foam to the scanner lid instead. This example image is not perfectly black. It's dark gray with the same dust and nonuniformity that was present in the prior image.
inpict = imread('checkblack.jpg');
graypict = im2gray(inpict);
mask = imbinarize(graypict);
mask = imfill(mask,'holes');
mask = bwareafilt(mask,1);
imshow(mask,'border','tight')
S = regionprops(mask,'minferetproperties','boundingbox');
angle = S.MinFeretAngle-90;
[mask rect] = imcrop(mask,S.BoundingBox);
mask = imrotate(mask,angle,'nearest');
S = regionprops(mask,'boundingbox');
outpict = imcrop(inpict,rect);
outpict = imrotate(outpict,angle,'bilinear');
outpict = imcrop(outpict,S.BoundingBox);
imshow(outpict,'border','tight')
Not only is this more robust, it's significantly faster. It could probably be simplified further.
In the first example, we can't rely on subject-background contrast to tell us where the object edges are. Without that assurance, and the assumption that the subject can be presented in any location or orientation, we have to make some huge leaps of faith that will almost certainly fail. We have to rely on the text/lines being bold enough to give us the dominant orientation peaks. If the checks have some sort of large scale pattern, that could easily ruin our ability to find the orientation. For example:
We have to rely on subtle shadows and text contrast to avoid cutting off the routing number. I should point out that when I say "subtle", I mean that the object edges differ from the local background by only a few LSBs in a lot of places.
In the second example, we used a dead-simple change to the physical imaging setup to help ensure that we have good subject-background contrast. That means that we can more reliably get a mask that cleanly isolates the subject. We can get orientation information directly from the mask without needing to rely on any of the internal feature contrast (e.g. text,lines) of the object.
There is one other minor benefit to scanning things on a black background, and that's simply that it reduces print-through. If you're scanning on a white background, you may find that scans of a double-sided print tend to be polluted with the faint image of the text on the backside of the page. It probably doesn't matter for checks, but it's one thing to consider. Plenty of scanners actually come with black covers instead of white, but white has its advantages too.