2

I did some experiment on the Affine function. I applied the transformation matrix I got from Air-lab to moving image with skimage, opencv and vips. Can Vips achieve the same result as the other two? I think vips did a lot pading for the result image. But I just need the type of pading like the other two. Vips is supper fast dealing with large WSIs. I don't think cv or skimage can do it as fast as vips.

vips_image = moving_image_vips.affine((T[0][0],
                                       T[0][1],
                                       T[1][0],
                                       T[1][1]),
                                      idx = T[0][2], 
                                      idy = T[1][2]
                                     )
warped_sk_image = skimage.transform.warp(np_moving_image.numpy(), 
                                         nverse_map=Tinv
                                        )
warped_cv2_image = cv2.warpAffine(moving_image.numpy(), 
                                  T[0:2, :], 
                                  (fixed_image.size[1], fixed_image.size[0])
                                 )

Here are the results I got from airlab skimage opencv and vips results I got from airlab skimage opencv and vips

mosc9575
  • 5,618
  • 2
  • 9
  • 32
fred
  • 21
  • 1
  • Also asked here: https://github.com/libvips/pyvips/issues/226 Please don't cross-post questions -- if I have to answer the same question twice it makes extra unnecessary work. – jcupitt Jan 04 '21 at 14:25

1 Answers1

0

You should set the oarea argument of affine to constrain the box.

Try for example oarea=(0,0,target_width,target_height).

0-_-0
  • 1,313
  • 15
  • 15