Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

YooSunYoung
Copy link
Member

@YooSunYoung YooSunYoung commented Jun 12, 2024

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.

image

@YooSunYoung YooSunYoung changed the title Image alignment Image alignment example notebook Jun 12, 2024
@YooSunYoung YooSunYoung requested a review from nvaytet June 13, 2024 06:17
@YooSunYoung YooSunYoung added the documentation Improvements or additions to documentation label Jun 13, 2024
@YooSunYoung YooSunYoung requested a review from MridulS June 13, 2024 07:55
"metadata": {},
"outputs": [],
"source": [
"def shift_pixels(image: np.ndarray, shift_x: int = 0, shift_y: int = 0) -> np.ndarray:\n",
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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 ...!!)

Copy link
Member

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",
Copy link
Member

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.

Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

2 participants