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

New background correction option and improved junge calculation #314

Merged
merged 37 commits into from
Oct 5, 2024

Conversation

arsalanmstn
Copy link
Contributor

The 'get_j' function is now modified to handle zero_value RuntimeWarning encountered in np.log(number_distribution[ind])

Arsimstn and others added 20 commits September 16, 2024 10:08
Silcam.py updated for bayer_rg8 images
Bayer conversion function name changed from brg8 to bayer_rgb8. Pyopia version (__init__) changed to 2.5.0.
format_load is now updated in SilCamLoad Class
Updated bayer conversion code to check the intensity range of converted rgb image. It raises an error if it exceeds 0-255, and if the max and min values change.
Final check was added for input image dimension (similar to mono).
The docstring of SilCamLoad class has been updated.
Checked by Flake8.
The "modify_config" has been modified to handle the pixel_size some other minor modifications of "modify_value"
Version has changed
The "get_j" function is now modified to handle zero values in number_distribution[ind]
… imbg SINTEF#315

A new function added to divide the raw images by bg images. Zero_value pixels handled by changing them to 1/255
@nepstad nepstad changed the title Updated statistics.py New background correction option and improved junge calculation Sep 25, 2024
@nepstad
Copy link
Collaborator

nepstad commented Sep 25, 2024

This is a good addition. The new background correction method should also be possible to set from the config file. We should consider adding the required logic in this pull request, and updating the documentation.

pyopia/background.py Outdated Show resolved Hide resolved
pyopia/background.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@nepstad nepstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I suggest also updating the background notebook in the docs/ folder with a simple example of how to use this new functionality, and perhaps compare the result of division and subtraction approach.

Copy link
Collaborator

@emlynjdavies emlynjdavies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest this is version 2.6.0, since it introduces a new functionality

@arsalanmstn
Copy link
Contributor Author

suggest this is version 2.6.0, since it introduces a new functionality

Hei @emlynjdavies,

Would you please add couple of empty images (images with zero particles) into oil.zip [pyopia.exampledata.get_file_from_pysilcam_blob('oil.zip')] for background correction? In this case we can show the differences between subtraction and division in a nicer way in the background notebook in the docs/ folder. The current notebook contains white-color circles in the corrected image!!!

@emlynjdavies
Copy link
Collaborator

suggest this is version 2.6.0, since it introduces a new functionality

Hei @emlynjdavies,

Would you please add couple of empty images (images with zero particles) into oil.zip [pyopia.exampledata.get_file_from_pysilcam_blob('oil.zip')] for background correction? In this case we can show the differences between subtraction and division in a nicer way in the background notebook in the docs/ folder. The current notebook contains white-color circles in the corrected image!!!

The oil directory is intended to just contain oil images. You can use a few (e.g. 10) of the oil images to create the background (doesn't need to be clean images, just as long as you have enough moving droplets that they average out ok)

@arsalanmstn
Copy link
Contributor Author

Hei all,

I made some changes in correct_im_accurate()/background.py. I realized that if the background is not clean enough, the division mode would produce a corrected image out of the (0,1) range-a dark image!!!. So, I used couple of extra lines to handle the problem (clipping and shifting negative values to zero for division mode). The background notebook is now modified to show the two different methods of subtraction and division, however, for some reasons, it does not pass the pipeline_holo_test(). I had the same problem when I passed the divide_bg = True as the default value, and changed it to False. I also had to change the version in init.py from '2.6.2' to '2.6.3' to pass the version check.

@emlynjdavies
Copy link
Collaborator

Hei all,

I made some changes in correct_im_accurate()/background.py. I realized that if the background is not clean enough, the division mode would produce a corrected image out of the (0,1) range-a dark image!!!. So, I used couple of extra lines to handle the problem (clipping and shifting negative values to zero for division mode). The background notebook is now modified to show the two different methods of subtraction and division, however, for some reasons, it does not pass the pipeline_holo_test(). I had the same problem when I passed the divide_bg = True as the default value, and changed it to False. I also had to change the version in init.py from '2.6.2' to '2.6.3' to pass the version check.

Excellent. I think it is best that @nepstad take a final review on this one ;)

@nepstad
Copy link
Collaborator

nepstad commented Oct 1, 2024

Hei all,
I made some changes in correct_im_accurate()/background.py. I realized that if the background is not clean enough, the division mode would produce a corrected image out of the (0,1) range-a dark image!!!. So, I used couple of extra lines to handle the problem (clipping and shifting negative values to zero for division mode). The background notebook is now modified to show the two different methods of subtraction and division, however, for some reasons, it does not pass the pipeline_holo_test(). I had the same problem when I passed the divide_bg = True as the default value, and changed it to False. I also had to change the version in init.py from '2.6.2' to '2.6.3' to pass the version check.

Excellent. I think it is best that @nepstad take a final review on this one ;)

I think it looks good now!

@nepstad
Copy link
Collaborator

nepstad commented Oct 2, 2024

suggest this is version 2.6.0, since it introduces a new functionality

The version should be changed to 2.7.0, since the main branch is on 2.6.2 now.

pyopia/__init__.py Outdated Show resolved Hide resolved
@nepstad nepstad merged commit 338fa7e into SINTEF:main Oct 5, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working minor new feature intended for changes that require bumping MINOR version. New features that are backwards-compatible.
Projects
None yet
4 participants