Comment 15 for bug 340203

Revision history for this message
danh (danh-archive) wrote : i think skew angle should be unchanged for 180 degree rotation in plane

Hi Raj,

Thanks for coming up with a plan to implement Matt's upside-down
scanning design.

For reference, Matt's idea was to turn right-to-left books
upside down and then treat them as left-to-right, with
adjustments to be made in subsequent processing. At our
meeting we came to a consensus that we'd make these adjustments
before anything hit the cluster (due to concerns both you
and Hank had).

The algorithm you suggested to me was:
  (1) Prior to republishing activity, add a flag to the
      scandata file signifying that the contents of that
      file would have to be modified.
  (2) In RePublisher-checkin.php add code to look at that
      flag, and if it was set, loop over the per-page data
      in the scandata file and:
      (a) swap handsides (left -> right, right-> left)
      (b) fix the rotate degrees (basically negate the +/- 90
          degree angles)
      (c) fix the skew
      (d) fix the crop box
  (3) Clear the flag set in step (1).

You also said that skew was applied first, then cropping, and
that the scandata functioned, at least in part, as a set of
instructions for further processing.

For further context, i believe that you told me about a year
ago that the rotation we do takes place about the center
of the image.

So i've attempted to code up your implementation (twice
in fact, as the first time i think i got it wrong).

My belief is that the skew angle actually remains
exactly the same.

That's just because if you rotate the plane 180 degrees
about any point, the slope of every line remains
unchanged (although where it lies, where it crosses
the coordinate axes, etc will all change).

Further, the coordinates of the corners of the
crop boxes all change according to the formulas
   x_new = total_width - (x_old + crop_width)
   y_new = total_height - (y_old + crop_height)
so i computed the new crop box corner according
to these formulas.

Since the scandata serves as a set of instructions
for image adjustment, if the original crop box was
correct (i.e., if it was originally correct to
rotate about the center by a certain angle, and then
crop to a certain box) the new crop box should also
be correct because it describes geometrically the
same sequence of instructions to be performed
on the image.

Here's an example of a right-to-left book (hand-made
per Mang's suggestion) where the crops are all very
non-centered but seem to survive the processing:
   http://www.archive.org/details/zdanh_test_018h_rl

(I can show the original to anybody who wants to see it.)

Here's an example of a (fake!) right-to-left book,
scanned upside down, which i think shows that the text seems
to be deskewed from the originals:
   http://www.archive.org/details/zdanh_test_018f_rl

Thanks in advance for any corrections or advice or
criticism from anybody about this.

dan