I need to process series of scans through crop and rotate.
At first I have to specify that scans come out straightened neither vertically nor horizontally. I might get straightened scans, too. It depends on how the scanner operator put them into the scanning machine.
Next I need to say that the image you get after each scan, includes not only the scanned page or map (I'm scanning old books and maps) but It does include some background as well.
First problem: I need to rotate the image so that it gets straightened vertically and horizontally (when this is possible; I said I'm working with old stuff which is often spoiled). I can't just rotate the image because, as I said it includes a background and the image could not be straightened in base of it.
Second problem: I need to crop the image because sometimes I don't need all the background that I get right after the scan. But I need some of it. That means the crop needs to leave a couple centimeters of background as border. Third problem: I'm working on very big .tif images (600dpi). The output needs to have the same dimensional parameters as the input. I'm not allowed to work with compressed or different formats.
I tried with canny, findContours, threshold functions but I couldn't get away with it. I need your help.
At first I have to specify that scans come out straightened neither vertically nor horizontally. I might get straightened scans, too. It depends on how the scanner operator put them into the scanning machine.
Next I need to say that the image you get after each scan, includes not only the scanned page or map (I'm scanning old books and maps) but It does include some background as well.
First problem: I need to rotate the image so that it gets straightened vertically and horizontally (when this is possible; I said I'm working with old stuff which is often spoiled). I can't just rotate the image because, as I said it includes a background and the image could not be straightened in base of it.
Second problem: I need to crop the image because sometimes I don't need all the background that I get right after the scan. But I need some of it. That means the crop needs to leave a couple centimeters of background as border. Third problem: I'm working on very big .tif images (600dpi). The output needs to have the same dimensional parameters as the input. I'm not allowed to work with compressed or different formats.
I tried with canny, findContours, threshold functions but I couldn't get away with it. I need your help.