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

Multichannel Images #34

Closed
jn31 opened this issue Mar 5, 2019 · 3 comments
Closed

Multichannel Images #34

jn31 opened this issue Mar 5, 2019 · 3 comments

Comments

@jn31
Copy link

jn31 commented Mar 5, 2019

Hello,
I am trying to use your library for registration of a series of 13 images. They have four channels (RGB + IR). When i use the similarity func. on all four channels they all have slightly different translation and rotation results. Could it be possible to just calculate the transformation data on all 4 channels without actually transforming them (would save time) and then choose a transformation of a single channel (the one with the best success rate) and apply it to all 4 ? The 4 channels would then align when they are written to a single image.

Could you also please define the success rate ? How is it calculated ?

Nice Greetings, Jure

@akatav
Copy link

akatav commented Feb 20, 2020

hi @jn31 can you please post your code here ? i am trying to get imreg_dft working for a similar problem too (4 channels, 3d stack of images) but i get an error - Images must have the same shape.

@jn31
Copy link
Author

jn31 commented Feb 20, 2020

Hello!

I have had multiple 4 channel images (R,G,B,IR). For the imreg_dfr similarity function you have to choose one of the color channels to run on. So i just used the function:

result = ird.similarity(template_img[0], subject_img[0]], numiter=1, order=1)

Where template_img[0] and subject_img[0] are 2D numpy arrays.

template_img.shape=(N,y,x)
template_img[0].shape=(y,x)

Where N is number of channels, y numbers of rows and x number of collums.

Out of the similarity function you get a result dictionary with the scale, translation and rotation values. Then you transform all of the 4 channels with the same paramaters:

subject_img[0]= ird.transform_img(subject_img[0], scale=result['scale'], angle=result['angle'], tvec=result['tvec'], mode='constant', bgval=0, order=1)
subject_img[1]= ird.transform_img(subject_img[1], scale=result['scale'], angle=result['angle'], tvec=result['tvec'], mode='constant', bgval=0, order=1)
subject_img[2]= ird.transform_img(subject_img[2], scale=result['scale'], angle=result['angle'], tvec=result['tvec'], mode='constant', bgval=0, order=1)
subject_img[3]= ird.transform_img(subject_img[3], scale=result['scale'], angle=result['angle'], tvec=result['tvec'], mode='constant', bgval=0, order=1)

I dont know your code, but the shape issue could come from not taking just one channel for either template or subject image or one image has a 3d shape and not a 2d shape.

The result vary based on the choice of the color channel (it must be the same channel on both images) so test which gives best results in your case.

So one more time, the fist two arguments of the similarity function are 2d numpy arrays presenting the same color channel in both images.

Nice grettings!

@jn31 jn31 closed this as completed Feb 20, 2020
@jn31 jn31 reopened this Feb 20, 2020
@matejak
Copy link
Owner

matejak commented Jul 8, 2020

The success correlates with the contrast in the power spectrum. See _get_success. And yes, you have correctly found out that you can use the similarity function and the succes, which is part of its result.

@matejak matejak closed this as completed Jul 8, 2020
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

No branches or pull requests

3 participants