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

Blur Animation source code and simplified output #328

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

Conversation

marcodallavecchia
Copy link
Contributor

Hello everyone!
I've seen from this issue, that we were looking to implement a better blur animation figure for section 06-blurring.

I've implemented a Python script that creates this animation with Matplotlib. Here are a few points:

  • I created a simple single-channel 30x30 pixels image of a letter A (using ImageJ) → available in episodes/data/A.tif
  • I exported the animation output directly in episodes/fig/blur-demo.gif
  • The animation has as a first frame the complete blurred image (for the print version, as described in the issue)
  • I chose more or less arbitrarily the colors → please let me know which colors you think could be better / more accessible
  • The code works but it's not the cleanest nor the most structured. But I tried to keep it well documented.
  • I've attached a small README and env.yml file for the requirements
  • Of course, with this script, anyone can change the source image, colors, speed and more of the animation and create a better version if desired.

A final extra point from my side: I'm a big believer that every output should be associated with its source-code, especially in the carpentries context where we are trying to keep things reproducible. In this case, I couldn't find the code used to create the previous version of the blur-demo.gif so I took the freedom to create a episodes/files/source-code/ directory, where we could pool together all the code snippets for generating all the output that would later feed on the website (this is where my current create_blur_animation.py file is). I am unsure if this is the best place to have such folder, maybe in the root could even be better for clear reference.

I hope this is helpful for the issue and course material. I am open to improve it in the near future after some feedback!

Marco Dalla Vecchia added 2 commits June 20, 2024 16:24
…f a single-channel image of letter A. I added the A.tif image in data and the exported animation directly into the fig directory
Copy link

github-actions bot commented Jun 20, 2024

Thank you!

Thank you for your pull request 😃

🤖 This automated message can help you check the rendered files in your submission for clarity. If you have any questions, please feel free to open an issue in {sandpaper}.

If you have files that automatically render output (e.g. R Markdown), then you should check for the following:

  • 🎯 correct output
  • 🖼️ correct figures
  • ❓ new warnings
  • ‼️ new errors

Rendered Changes

🔍 Inspect the changes: https://github.com/datacarpentry/image-processing/compare/md-outputs..md-outputs-PR-328

The following changes were observed in the rendered markdown documents:

 data/letterA.tif (new)                             | Bin 0 -> 1136 bytes
 fig/blur-demo.gif                                  | Bin 32633468 -> 567305 bytes
 .../06-blurring/create_blur_animation.py (new)     | 164 +++++++++++++++++++++
 3 files changed, 164 insertions(+)
What does this mean?

If you have source files that require output and figures to be generated (e.g. R Markdown), then it is important to make sure the generated figures and output are reproducible.

This output provides a way for you to inspect the output in a diff-friendly manner so that it's easy to see the changes that occur due to new software versions or randomisation.

⏱️ Updated at 2024-11-28 00:01:59 +0000

github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
github-actions bot pushed a commit that referenced this pull request Jun 21, 2024
@uschille uschille self-assigned this Aug 21, 2024
github-actions bot pushed a commit that referenced this pull request Nov 28, 2024
@uschille
Copy link
Contributor

Thank you very much @marcodallavecchia for this contribution. We discussed this in today's Curriculum Advisory Committee meeting. We do like the new animation and envision that it can be included in the blurring episode.

Regarding the location of the script, we do not have an ideal solution but our consensus (as of now) is to keep code scripts that re-generate figures in episodes/fig/source/. The reasoning is that we do not want to scare or distract learners with more complex code than what is covered in the lesson, and we believe they are less likely to look into a subfolder of the fig/ directory than the files/ directory. I have taken the liberty to update the branch accordingly.

One suggestion I have is that you might use a default value for the kernel size so that maintainers can reproduce the figure without having to guess the kernel size. I tend to prefer scripts that do not require interactive input for reproducibility.

There may be other feedback on the script, so I'll keep the pull request open for others to comment - 👋 @mkcor.

@marcodallavecchia
Copy link
Contributor Author

@uschille thanks a lot for coming back to this!

  • I can definitely add a default kernel size or even remove the user input completely for reproducibility purposes.
  • Regarding the organization, I agree with the folder structure you opted for, mine was just a proposition, because I couldn't find any code to create the previous animation
  • I will wait to make any changes to see if any other feedback reaches my ear any time soon

👋 Marco

@K-Meech
Copy link
Contributor

K-Meech commented Nov 30, 2024

Thanks @marcodallavecchia - the new blur animation looks great! I'd agree with @uschille 's comments above.

We will need to update the text in the blurring episode to match this new animation. For example, above this gif it says This animation shows how the blur kernel moves along in the original image in order to calculate the colour channel values for the blurred image. - so we'd need to do some re-wording to make it clear that it's grayscale etc. Potentially it would be good to replace all the early parts of the episode that reference cat images to use the grayscale A instead. @uschille - what's your preference for this? We could handle this in a separate PR, but then we'd need to keep the original blur-demo.gif around in the meantime.

@uschille
Copy link
Contributor

We will need to update the text in the blurring episode to match this new animation.

Yes, it will require a bit of work to incorporate the new animation in the lesson.

@marcodallavecchia would you perhaps be willing to give it a try?

I'd suggest to keep this PR open while we are working on it. Does this sound reasonable @K-Meech?

@K-Meech
Copy link
Contributor

K-Meech commented Dec 1, 2024

Sounds good to me @uschille !

@marcodallavecchia
Copy link
Contributor Author

Dear @uschille and @K-Meech,
Thanks a lot for the feedback and having the foresight of the needed changes in the lecture itself. I would gladly take the challenge to try and adapt it, given some time (probably until after the holidays).

Just to clarify, should I open a new PR only with the lecture changes, or should I integrate the text changes with the blur animation code altogether?

@K-Meech
Copy link
Contributor

K-Meech commented Dec 3, 2024

Great - thanks @marcodallavecchia ! I'd say incorporate it directly into this PR, along with the blur animation code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants