Update mdr_pdf_parser.py
Browse files- mdr_pdf_parser.py +6 -6
mdr_pdf_parser.py
CHANGED
|
@@ -2819,20 +2819,20 @@ class MDRExtractionEngine:
|
|
| 2819 |
print(" Engine: Analyzing image...")
|
| 2820 |
# --- START: ADDED CLAHE PREPROCESSING ---
|
| 2821 |
# Convert PIL Image to OpenCV BGR format
|
| 2822 |
-
ori_im_cv = cv2.cvtColor(np.array(image.convert("RGB")), cv2.COLOR_RGB2BGR)
|
| 2823 |
|
| 2824 |
-
gray_cv = cv2.cvtColor(ori_im_cv, cv2.COLOR_BGR2GRAY)
|
| 2825 |
-
clahe_obj = cv2.createCLAHE(clipLimit=3.0, tileGridSize=(8, 8))
|
| 2826 |
-
enhanced_gray_cv = clahe_obj.apply(gray_cv)
|
| 2827 |
# Convert back to BGR for downstream components that might expect 3 channels
|
| 2828 |
# (even if they only use one, like the detector)
|
| 2829 |
# And then back to PIL Image for the optimizer
|
| 2830 |
-
processed_cv_bgr = cv2.cvtColor(enhanced_gray_cv, cv2.COLOR_GRAY2BGR)
|
| 2831 |
|
| 2832 |
# Convert the processed OpenCV image back to PIL Image for the optimizer
|
| 2833 |
# The optimizer expects a PIL Image.
|
| 2834 |
# The image passed to optimizer will now be the CLAHE'd version.
|
| 2835 |
-
processed_pil_image = pil_fromarray(cv2.cvtColor(processed_cv_bgr, cv2.COLOR_BGR2RGB))
|
| 2836 |
print(" Engine: CLAHE preprocessing applied to input image.")
|
| 2837 |
optimizer = MDRImageOptimizer(processed_pil_image, adjust_points)
|
| 2838 |
print(" Engine: Initial OCR...")
|
|
|
|
| 2819 |
print(" Engine: Analyzing image...")
|
| 2820 |
# --- START: ADDED CLAHE PREPROCESSING ---
|
| 2821 |
# Convert PIL Image to OpenCV BGR format
|
| 2822 |
+
#ori_im_cv = cv2.cvtColor(np.array(image.convert("RGB")), cv2.COLOR_RGB2BGR)
|
| 2823 |
|
| 2824 |
+
#gray_cv = cv2.cvtColor(ori_im_cv, cv2.COLOR_BGR2GRAY)
|
| 2825 |
+
#clahe_obj = cv2.createCLAHE(clipLimit=3.0, tileGridSize=(8, 8))
|
| 2826 |
+
#enhanced_gray_cv = clahe_obj.apply(gray_cv)
|
| 2827 |
# Convert back to BGR for downstream components that might expect 3 channels
|
| 2828 |
# (even if they only use one, like the detector)
|
| 2829 |
# And then back to PIL Image for the optimizer
|
| 2830 |
+
#processed_cv_bgr = cv2.cvtColor(enhanced_gray_cv, cv2.COLOR_GRAY2BGR)
|
| 2831 |
|
| 2832 |
# Convert the processed OpenCV image back to PIL Image for the optimizer
|
| 2833 |
# The optimizer expects a PIL Image.
|
| 2834 |
# The image passed to optimizer will now be the CLAHE'd version.
|
| 2835 |
+
processed_pil_image = image #pil_fromarray(cv2.cvtColor(processed_cv_bgr, cv2.COLOR_BGR2RGB))
|
| 2836 |
print(" Engine: CLAHE preprocessing applied to input image.")
|
| 2837 |
optimizer = MDRImageOptimizer(processed_pil_image, adjust_points)
|
| 2838 |
print(" Engine: Initial OCR...")
|