cctbx / cctbx_project

Computational Crystallography Toolbox
https://cci.lbl.gov/docs/cctbx
Other
214 stars 111 forks source link

cctbx.image_viewer: offsets of "Picture" and "Readout" coordinates #71

Open dagewa opened 6 years ago

dagewa commented 6 years ago

As discussed on the dials-support@lists.sourceforge.net mailing list, the image viewer coordinates displayed in the status bar do not match with the dxtbx Panel pixel coordinate system. The effect seems to vary with format. FormatCBFMiniPilatus has a single panel with coincident "Picture" and "Readout" coordinates. However, these are shifted by 1 whole pixel in both fast and slow directions.

If dials_regression is present, this can be demonstrated as follows:

dials.import $(libtbx.find_in_repositories dials_regression)/centroid_test_data/centroid_0001.cbf slow_fast_beam_centre=0,0
dials.image_viewer datablock.json

Although this example uses the dials.image_viewer, the behaviour comes from the cctbx.image_viewer upstream. The intention was to place the cross at 0,0 in the Panel's pixel coordinate system. It is displayed at a "Readout" coordinate of 0,0, but this overlays the point 1,1 in the pixel coordinate system.

corner

Other formats have different issues. For example

dials.import 1_000001.img slow_fast_beam_centre=0,0
dials.image_viewer datablock.json

This time the cross is where we expect, but the Picture and Readout coordinates are offset by 0.5 pixels

corner2

It even matters if the image is imported or viewed directly. For example, dials.image_viewer 1_000001.img opens the same image, but the Picture and Readout coordinates no longer coincide in the top left corner.

corner

Basic expectations discussed on the mailing list

Hovering in the center of the origin pixel shows:

Hovering near the corner of the origin pixel closest to the corner of the panel shows:

The Picture and Readout values can in general differ, as the Picture involves an orthographic projection from the laboratory coordinate system. However, these frames should be aligned such that (0,0) of the Picture coincides with (0,0) of the Readout for Panel 0.

The display should be consistent whether the image viewer is passed an image file or a datablock.json

graeme-winter commented 5 years ago

Suspect the best approach with this (rather venerable and overlooked) issue would be to define the expected behaviour then implement to that - do we have a clear set of expectations?

I can see this becoming more complex with multi-panel (co-planar or non-co-planar) detectors as an additional challenge