Skip to content

Commit

Permalink
fix Workspace.save_image_file args
Browse files Browse the repository at this point in the history
  • Loading branch information
bertsky committed Mar 19, 2022
1 parent 8841abc commit 200313f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 32 deletions.
18 changes: 6 additions & 12 deletions ocrd_cis/ocropy/binarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,8 @@ def process_page(self, page, page_image, page_xywh, zoom, page_id, file_id):
file_id += '.IMG-BIN'
features += ',binarized'
file_path = self.workspace.save_image_file(
bin_image,
file_id,
page_id=page_id,
file_grp=self.output_file_grp)
bin_image, file_id, self.output_file_grp,
page_id=page_id)
# update PAGE (reference the image file):
page.add_AlternativeImage(AlternativeImageType(
filename=file_path,
Expand Down Expand Up @@ -263,10 +261,8 @@ def process_region(self, region, region_image, region_xywh, zoom, page_id, file_
file_id += '.IMG-BIN'
features += ',binarized'
file_path = self.workspace.save_image_file(
bin_image,
file_id,
page_id=page_id,
file_grp=self.output_file_grp)
bin_image, file_id, self.output_file_grp,
page_id=page_id)
# update PAGE (reference the image file):
region.add_AlternativeImage(AlternativeImageType(
filename=file_path,
Expand Down Expand Up @@ -306,10 +302,8 @@ def process_line(self, line, line_image, line_xywh, zoom, page_id, region_id, fi
file_id += '.IMG-BIN'
features += ',binarized'
file_path = self.workspace.save_image_file(
bin_image,
file_id,
page_id=page_id,
file_grp=self.output_file_grp)
bin_image, file_id, self.output_file_grp,
page_id=page_id)
# update PAGE (reference the image file):
line.add_AlternativeImage(AlternativeImageType(
filename=file_path,
Expand Down
6 changes: 2 additions & 4 deletions ocrd_cis/ocropy/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,8 @@ def process_segment(self, segment, segment_mask, segment_polygon, neighbours,
segment_image = crop_image(segment_image,box=segment_bbox)
# update METS (add the image file):
file_path = self.workspace.save_image_file(
segment_image,
file_id=file_id + '.IMG-CLIP',
page_id=page_id,
file_grp=self.output_file_grp)
segment_image, file_id + '.IMG-CLIP', self.output_file_grp,
page_id=page_id)
# update PAGE (reference the image file):
segment.add_AlternativeImage(AlternativeImageType(
filename=file_path,
Expand Down
6 changes: 2 additions & 4 deletions ocrd_cis/ocropy/denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ def process_segment(self, segment, segment_image, segment_xywh, zoom, page_id, f
maxsize=self.parameter['noise_maxsize']/zoom*300/72) # in pt
# update METS (add the image file):
file_path = self.workspace.save_image_file(
bin_image,
file_id + '.IMG-DESPECK',
page_id=page_id,
file_grp=self.output_file_grp)
bin_image, file_id + '.IMG-DESPECK', self.output_file_grp,
page_id=page_id)
# update PAGE (reference the image file):
segment.add_AlternativeImage(AlternativeImageType(
filename=file_path,
Expand Down
6 changes: 2 additions & 4 deletions ocrd_cis/ocropy/deskew.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,8 @@ def _process_segment(self, segment, segment_image, segment_coords, segment_id, p
segment_coords['features'] += ',deskewed'
# update METS (add the image file):
file_path = self.workspace.save_image_file(
segment_image,
file_id + '.IMG-DESKEW',
page_id=page_id,
file_grp=self.output_file_grp)
segment_image, file_id + '.IMG-DESKEW', self.output_file_grp,
page_id=page_id)
# update PAGE (reference the image file):
segment.add_AlternativeImage(AlternativeImageType(
filename=file_path,
Expand Down
4 changes: 2 additions & 2 deletions ocrd_cis/ocropy/dewarp.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def process(self):
file_path = self.workspace.save_image_file(
dew_image,
file_id + '_' + region.id + '_' + line.id + '.IMG-DEWARP',
page_id=input_file.pageId,
file_grp=self.output_file_grp)
self.output_file_grp,
page_id=input_file.pageId)
# update PAGE (reference the image file):
alternative_image = line.get_AlternativeImage()
line.add_AlternativeImage(AlternativeImageType(
Expand Down
10 changes: 4 additions & 6 deletions ocrd_cis/ocropy/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,8 @@ def _process_element(self, element, ignore, image, coords, element_id, file_id,
element_array[sepmask] = np.amax(element_array) # clip to white/bg
image_clipped = array2pil(element_array)
file_path = self.workspace.save_image_file(
image_clipped, file_id + '.IMG-CLIP',
page_id=page_id,
file_grp=self.output_file_grp)
image_clipped, file_id + '.IMG-CLIP', self.output_file_grp,
page_id=page_id)
element.add_AlternativeImage(AlternativeImageType(
filename=file_path, comments=coords['features'] + ',clipped'))
else:
Expand Down Expand Up @@ -768,9 +767,8 @@ def _process_element(self, element, ignore, image, coords, element_id, file_id,
element_array[sep_bin] = np.amax(element_array) # clip to white/bg
image_clipped = array2pil(element_array)
file_path = self.workspace.save_image_file(
image_clipped, file_id + '.IMG-CLIP',
page_id=page_id,
file_grp=self.output_file_grp)
image_clipped, file_id + '.IMG-CLIP', self.output_file_grp,
page_id=page_id)
# update PAGE (reference the image file):
element.add_AlternativeImage(AlternativeImageType(
filename=file_path, comments=coords['features'] + ',clipped'))
Expand Down

0 comments on commit 200313f

Please sign in to comment.