Process the image of the text document Version 2 (python)

Action group: Robin OCR

Description

The action performs automatic image processing of a text document to improve its quality.

Action icon

Parameters and their settings

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
ImageThe path to the image file of the document to be processed.Robin.FilePath
Yes
Page numberThe page number of the file to be processed. If the field is not filled in, the processing will be applied to all pages of the file. If the image is not in tiff or tif format, the field will not be taken into account.Robin.Numeric
No
Brightness and contrast preprocessingThe page number of the file to be processedIf the value is «true», then the brightness and contrast of the image will be corrected at the beginning of processing. If the value of «Brightness and Contrast Postprocessing» is also «true», then postprocessing will be used by default.Robin.BooleantrueNo
Correct distortionsIf the value is «true», then all distortions in the plane will be corrected in the image.Robin.BooleantrueNo
Align horizontallyIf the value is «true», then the image will be aligned horizontally.Robin.BooleantrueNo
Brightness and contrast post- processingIf the value is «true», then the brightness and contrast of the image will be corrected at the end of processing. If the value «Brightness and Contrast Preprocessing» is also true, then postprocessing will be used by default.Robin.BooleantrueNo
Folder pathThe path to the folder where the processed image file will be saved. If the field remains empty, the file will be saved in the source folder.Robin.FolderPathC:\doc\imgNo
File nameThe name of the processed image file. If the field remains empty, the original file name will be saved.Robin.String
No
FormatThe format in which the processed image file will be saved. If the field remains empty, the file is saved in the same format as the original image.Robin.String
No
OverwriteIf the value is «true» and an image file with the same name and extension exists in the specified folder, then the new file will overwrite it. If «false», the file will not be overwritten and the action will return an error.Robin.BooleantrueNo
Results
ResultThe path to the processed image file.Robin.FilePath

Special conditions of use  

  1. The action works correctly with document images.
  2. Valid image extensions: jpg, jpeg, jpe, ppm, bmp, dib, png, tif , tiff. If a different extension is selected, the action will generate an error. Error description: "An invalid extension is specified".
  3. If the image is multi-page, the user can specify the page to be processed. If no page is specified, the processing will be applied to the whole file. If the submitted image is not multi-page, the "Page number" parameter is ignored.
  4. If an invalid file page number is specified, the action will generate an error. Error description: "A nonexistent document page is specified.".
  5. The user can change the name and path to save the processed image.
  6. If the user does not specify a file name, the original file name will be saved.
  7. If the user does not specify a folder path, the file will be saved in the original folder.
  8. If the user specifies a file name but does not specify a folder path, the file will be saved with the specified name in the source folder.
  9. If the user specifies a folder path but does not specify a file name, the file will be saved with the original name in the specified folder.
  10. If the user does not specify a file name and folder path, "Overwrite" = true must be filled in to overwrite the existing file, otherwise the action will generate an error (prescribed in step 12).
    The user can specify a new image extension by selecting it from the "Format" parameter. If the parameter is not filled in, the image will be saved in the original extension.
  11. The user can overwrite a file: if the overwrite parameter is "true" and a file with the same name and extension exists in the specified folder, the new file will overwrite it. If "false", the file will not be overwritten and the action will generate an error. Error description: "A file with the specified name and extension already exists."
  12. Options for image processing: Brightness and contrast preprocessing, Correct distortions, Align horizontally, Brightness and contrast post-processing.
  13. Preprocessing changes brightness and contrast more gently than postprocessing. But pre-processing can illuminate image boundaries that are necessary for other image processing parameters. Therefore, it is necessary to understand which specific processing parameters to apply to the image. If the user selects post-processing and brightness and contrast pre-processing, post-processing will be used by default.

Example of use 

Task

There is an image of a check on the desktop, you need to change the brightness and contrast of the image to the values: brightness - 50, contrast 20. 


Solution

Use the "Change brightness and contrast" action. 

Implementation

  1. Move the ""Change brightness and contrast" action to the workspace and set its parameters.

  2. Click on the "Start" button in the top panel. 

Result

The program robot completed successfully. The brightness and contrast of the image has been changed. 


Image after changing the brightness and contrast. 

  • Нет меток