Browse Source

Changed Normalizer output to bmp and dpi to 200

Thomas Chef 7 years ago
parent
commit
c9774f759d
3 changed files with 21 additions and 15 deletions
  1. 1 1
      PageNormalizer/pagenormalizer.cpp
  2. 14 8
      TestProject/book_settings.py
  3. 6 6
      TestProject/build.py

+ 1 - 1
PageNormalizer/pagenormalizer.cpp

@@ -30,7 +30,7 @@ PageNormalizer::PageNormalizer(const std::string inFile,const std::string outFil
 
     NormalizeImage();
 
-    outImage.save_jpeg( outFile.c_str() );
+    outImage.save_bmp( outFile.c_str() );
 }
 
 void PageNormalizer::NormalizeImage()

+ 14 - 8
TestProject/book_settings.py

@@ -1,9 +1,15 @@
-# Dynamic Input arguments. These very for every book that is scanned and for every scan
+# Dynamic Input arguments. These vary for every book that is scanned and for every scan
 refImg =   2                    # The image used as reference image
-coverImage = 1                  # Image used for cover (Will be placed 1st)
-firstLeftHandPage = 212          # The first image covering the left pages
-pageNoOfFirstLeftPage = 2       # The page number (printed in the book) of the first left-hand page that is scanned (An even number)
-cropX1 = 333                    # Crop coordinates of all the images
-cropY1 = 30
-cropX2 = 3342
-cropY2 = 2380
+coverImage = 3                  # Image used for cover (Will be placed 1st)
+firstLeftHandPage = 161          # The first image covering the left pages
+pageNoOfFirstLeftPage = 4       # The page number (printed in the book) of the first left-hand page that is scanned (An even number)
+cropX1 = 288                    # Crop coordinates of all the images Max size is 3240 = 45" at 72dpi
+cropY1 = 34
+cropX2 = 3726
+cropY2 = 2980
+
+# These are the original settings (To big)
+#cropX1 = 258                    # Crop coordinates of all the images
+#cropY1 = 50
+#cropX2 = 3674
+#cropY2 = 2453

+ 6 - 6
TestProject/build.py

@@ -108,13 +108,13 @@ print( '---------- Processing cover page  ----------' )
 # First convert the cover-page as it should be number one
 subprocess.call('../PageNormalizer/build-Mac/PageNormalizer ' + \
                 ' -i ' + covFilePath + \
-                ' -o ' + tpath+'/temp.jpg' + \
+                ' -o ' + tpath+'/temp.bmp' + \
                 ' -wref ' + tpath + '/ref_white.jpg' + \
                 ' -bref ' + tpath + '/ref_black.jpg' + \
                 ' -s ' + settingsFile , shell=True)
 
 # Rotate the image and store it in the final position (output-folder)
-subprocess.call('jpegtran -rotate 270 -outfile ' + opath + '/page_'+str(1).zfill(numberNumericalsInName)+'.jpg ' + tpath+'/temp.jpg', shell=True)
+subprocess.call( 'sips -r 270 -s dpiHeight 200.0 -s dpiWidth 200.0 temp/temp.bmp --out ' + opath + '/page_'+str(1).zfill(numberNumericalsInName)+'.bmp ', shell=True)
 
 
 # Start doing the rest of the pages. Left pages first
@@ -125,13 +125,13 @@ for i in range( len(lHandSides) ):
     subprocess.call('../PageNormalizer/build-Mac/PageNormalizer ' + \
                     ' -q ' \
                     ' -i ' + lHandSides[i] + \
-                    ' -o ' + tpath+'/temp.jpg' + \
+                    ' -o ' + tpath+'/temp.bmp' + \
                     ' -wref ' + tpath + '/ref_white.jpg' + \
                     ' -bref ' + tpath + '/ref_black.jpg' + \
                     ' -s ' + settingsFile , shell=True)
 
     # Rotate the image
-    subprocess.call('jpegtran -rotate 90 -outfile ' + opath + '/page_'+str(leftPageNo).zfill(numberNumericalsInName)+'.jpg ' + tpath+'/temp.jpg', shell=True)
+    subprocess.call( 'sips -r 90 -s dpiHeight 200.0 -s dpiWidth 200.0 temp/temp.bmp --out ' + opath + '/page_'+str(leftPageNo).zfill(numberNumericalsInName)+'.bmp ', shell=True)
 
 
     leftPageNo = leftPageNo + 2 # Increase the page conter
@@ -144,13 +144,13 @@ for i in range( len(rHandSides) ):
     subprocess.call('../PageNormalizer/build-Mac/PageNormalizer ' + \
                     ' -q ' \
                     ' -i ' + rHandSides[i]  + \
-                    ' -o ' + tpath+'/temp.jpg' + \
+                    ' -o ' + tpath+'/temp.bmp' + \
                     ' -wref ' + tpath + '/ref_white.jpg' + \
                     ' -bref ' + tpath + '/ref_black.jpg' + \
                     ' -s ' + settingsFile , shell=True)
 
     # Rotate the image
-    subprocess.call('jpegtran -rotate 270 -outfile ' + opath + '/page_'+str(rightPageNo).zfill(numberNumericalsInName)+'.jpg ' + tpath+'/temp.jpg', shell=True)
+    subprocess.call( 'sips -r 270 -s dpiHeight 200.0 -s dpiWidth 200.0 temp/temp.bmp --out ' + opath + '/page_'+str(rightPageNo).zfill(numberNumericalsInName)+'.bmp ', shell=True)
     
     rightPageNo = rightPageNo + 2 # Increase the page conter