|
@@ 674-697 (lines=24) @@
|
| 671 |
|
|
| 672 |
|
alternative_image = None |
| 673 |
|
alternative_images = segment.get_AlternativeImage() |
| 674 |
|
if alternative_images: |
| 675 |
|
# (e.g. from segment-level cropping, binarization, deskewing or despeckling) |
| 676 |
|
if feature_selector or feature_filter: |
| 677 |
|
alternative_image = None |
| 678 |
|
# search from the end, because by convention we always append, |
| 679 |
|
# and among multiple satisfactory images we want the most recent: |
| 680 |
|
for alternative_image in reversed(alternative_images): |
| 681 |
|
features = alternative_image.get_comments() |
| 682 |
|
if (all(feature in features |
| 683 |
|
for feature in feature_selector.split(',') if feature) and |
| 684 |
|
not any(feature in features |
| 685 |
|
for feature in feature_filter.split(',') if feature)): |
| 686 |
|
break |
| 687 |
|
else: |
| 688 |
|
alternative_image = None |
| 689 |
|
else: |
| 690 |
|
alternative_image = alternative_images[-1] |
| 691 |
|
features = alternative_image.get_comments() |
| 692 |
|
if alternative_image: |
| 693 |
|
log.debug("Using AlternativeImage %d (%s) for segment '%s'", |
| 694 |
|
alternative_images.index(alternative_image) + 1, |
| 695 |
|
features, segment.id) |
| 696 |
|
segment_image = self._resolve_image_as_pil(alternative_image.get_filename()) |
| 697 |
|
segment_coords['features'] = features |
| 698 |
|
# transpose, if (still) necessary: |
| 699 |
|
if (orientation and |
| 700 |
|
not 'rotated-%d' % orientation in segment_coords['features'] and |
|
@@ 398-421 (lines=24) @@
|
| 395 |
|
|
| 396 |
|
alternative_image = None |
| 397 |
|
alternative_images = page.get_AlternativeImage() |
| 398 |
|
if alternative_images: |
| 399 |
|
# (e.g. from page-level cropping, binarization, deskewing or despeckling) |
| 400 |
|
if feature_selector or feature_filter: |
| 401 |
|
alternative_image = None |
| 402 |
|
# search from the end, because by convention we always append, |
| 403 |
|
# and among multiple satisfactory images we want the most recent: |
| 404 |
|
for alternative_image in reversed(alternative_images): |
| 405 |
|
features = alternative_image.get_comments() |
| 406 |
|
if (all(feature in features |
| 407 |
|
for feature in feature_selector.split(',') if feature) and |
| 408 |
|
not any(feature in features |
| 409 |
|
for feature in feature_filter.split(',') if feature)): |
| 410 |
|
break |
| 411 |
|
else: |
| 412 |
|
alternative_image = None |
| 413 |
|
else: |
| 414 |
|
alternative_image = alternative_images[-1] |
| 415 |
|
features = alternative_image.get_comments() |
| 416 |
|
if alternative_image: |
| 417 |
|
log.debug("Using AlternativeImage %d (%s) for page '%s'", |
| 418 |
|
alternative_images.index(alternative_image) + 1, |
| 419 |
|
features, page_id) |
| 420 |
|
page_image = self._resolve_image_as_pil(alternative_image.get_filename()) |
| 421 |
|
page_coords['features'] = features |
| 422 |
|
|
| 423 |
|
# crop, if (still) necessary: |
| 424 |
|
if (border and |