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

A quick hack for warping RGB images #19

Open
bsugerman opened this issue Oct 10, 2019 · 1 comment
Open

A quick hack for warping RGB images #19

bsugerman opened this issue Oct 10, 2019 · 1 comment

Comments

@bsugerman
Copy link

If you are willing to find the warp/displacement on a grayscale version of the image, but want to apply it to all 3 layers in the color version, then here is a simple hack to warp_image():

def warp_image(image, displacement):
    image_size = image.size
    grid = compute_grid(image_size[:2], dtype=image.dtype, device=image.device)
    out=image_from_numpy(np.empty(image_size),(),(),device=image.device,dtype=image.dtype)
    if len(image_size==2):
        out.image =  transformation.utils.F.grid_sample(image.image, displacement + grid)
    else:
        for i in range(image_size[-1]):
            out.image[...,i] = transformation.utils.F.grid_sample(image.image[...,i], displacement + grid)
return out
@asmagen
Copy link

asmagen commented Apr 1, 2020

@bsugerman I am using drop2 registration for histopathology images but the outputs are deformation_field_x.nii.gz and deformation_field_y.nii.gz deformation fields which I would like to apply on the RGB png image channels to get a registered png RGB image.

Is there a quick way to apply your function on an RGB png image and the deformation field gz field above?

Thanks

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

2 participants