-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image alignment example notebook #23
base: main
Are you sure you want to change the base?
Conversation
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def shift_pixels(image: np.ndarray, shift_x: int = 0, shift_y: int = 0) -> np.ndarray:\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to sound too harsh, but I think this is the wrong direction (but I know it's not always obvious when trying to figure these things out alone at a beamline).
All data, whether it is events in a nexus file or a tiff image, should be loaded as a DataArray
, with a position
coordinate for the pixel positions (and other coordinates, eg tof
?), and counts as the data
part of the data array.
Then, shifting the positions simply becomes a vector addition.
shift = sc.vector([-0.1, 0.25, 0.], unit='cm')
da.coords['position'] += shift
So I see limited value in this notebook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still couldn't convince people to use scipp here... and more precisely to convince people to get used to the scipp data structure.
and we needed it right now right here so I ended up doing it with numpy but maybe writing this in scipp would be a good example why we need to use it...?
Giving more background, we tried some fancy methods in opencv
to align the images but simply shifting the image by several pixels worked the best after all. So I thought it's worth documenting it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(And you don't sound too harsh:D ...!!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to write scripts or notebooks that don't use Scipp for a specific purpose like looking at data from an experiment, but they don't need to make it into the Ess reduction software.
The fact that people don't want to use Scipp at jparc is irrelevant I think? I would say that's their loss. Our task is to develop the software for Ess.
"\n", | ||
"fig, ax = plt.subplots(2, 2, figsize=(15, 10))\n", | ||
"im = ax[0, 0].imshow(ob_normalized)\n", | ||
"ax[0, 1].imshow(misaligned_normalized, cmap=im.cmap)\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loading the data as a DataArray
would then just use Plopp for plotting. This would also mean one could make use of other tools such as the instrument view.
But again, not sure much would be left in the notebook if shifting the positions is a simple vector addition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it doesn't matter even if it's short.
I'll rewrite it again though
Basic image alignment tool was needed during the beamtime at Senju, JParc for battery measurement.
I couldn't come up with the nice way to automate this feature, so I just made a documentation about what we did here.
Misaligned sample image is sth I made up using the background image.