-
Notifications
You must be signed in to change notification settings - Fork 14
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
Adding other padding methods #202
Comments
Which ones would you like to have? Also specify the essence of it (median of the whole image, of the rows/cols...). Do you need them in the |
BTW, do you have a use case when this is necessary? |
I am asking because for correlation just zero-padding usually works fine. |
Hi Tomas, I correlated rescaled fresnel diffraction patterns as described e.g. in https://aip.scitation.org/doi/pdf/10.1063/1.2719653 I also tested zero padding. There was a bright gradient which was stronger than the correlation peak it self. Image 1 zero padded data I can also try to zero pad in ufo but i did not find the command on read the docs there is only the link to opencls sampler_t documentation. |
And what happens when you apply sobel filter before the correlation? |
Don't do LR sobel, do really a 2D magnitude of the derivative and take a look at the peak. |
see e.g. how scikit-image does 2D sobel |
i used this scipy.ndimage.sobel but will also try the one you proposed. LR is only the filename of the inital image |
Don't use scipy, it doesn't do the 2D version, or use scipy and calculate the 2D magnitude yourself. |
|
Please send me an e-mail with a link to the two images you are trying to correlate, I will check it. |
It's better to first subtract the means of the two images (https://en.wikipedia.org/wiki/Cross-correlation#Zero-normalized_cross-correlation_(ZNCC). ifft2(fft2(LR - LR.mean()) * np.conjugate(fft2(HR - HR.mean(), s=LR.shape))).real gives the correct result below (with just zero-padding, the default when padding directly in numpy's |
Thank you! Do you know how to implement this in UFO: e.g. read path=2196Mn_LR_0p625_region1/rescaled/*.tif number=2500 ! SUBTRACT MEAN ! pad x=0 y=0 width=8192 height=8192 ! ... I found measure metric=mean and calculate but was not able to pass the result of measure to calculate. |
Unfortunately, that's not possible right now. |
Can this be implemented, or do you have an idea for a workaround? |
It certainly can be implemented, the question is how to make it in such a way that it's general enough for other operations (what if you want to multiply with standard deviation tomorrow?) 😉 I will need to think about it a little. In the meantime, can you remove the mean in python or fiji (both excellent scripting options)? |
Hi,
is it possible to add different padding methods to ufo? Very helpful would be a padding mode as in python numpy.pad mode=median.
I am aware that speed will be reduced compared to the default opencl "padding" modes.
Bests,
Mathias
The text was updated successfully, but these errors were encountered: