Generic image coordinate transformation using a matrix
Johannes Schönberger
jsch at demuc.de
Thu Sep 11 09:15:40 EDT 2014
You would have to reorder the dimensions of your coordinate matrix to `(2, 2832, 4256)`.
Johannes Schönberger
On Sep 11, 2014, at 4:56 AM, Maik Riechert <maik.riechert at arcor.de> wrote:
> I just tested it and it doesn't work yet.
> My image is an uint8 array of shape (2832, 4256, 3), and the coordinate array is float32 (2832, 4256, 2) but when using skimage.transform.warp(im, undistCoords) I get:
>
>
> Traceback (most recent call last):
> File ...
> imUndistorted = skimage.transform.warp(im, undistCoords)
> File "/home/mriecher/.local/lib/python2.7/site-packages/skimage/transform/_geometric.py", line 1153, in warp
> mode=mode, order=order, cval=cval)
> File "/usr/lib/python2.7/dist-packages/scipy/ndimage/interpolation.py", line 289, in map_coordinates
> raise RuntimeError('invalid shape for coordinate array')
> RuntimeError: invalid shape for coordinate array
>
> Looking at map_coordinates:
>
> if coordinates.shape[0] != input.ndim:
> raise RuntimeError('invalid shape for coordinate array')
>
> I tried some other array shapes but couldn't make it work. What's the correct way here?
>
> Maik
>
>
> Am Mittwoch, 10. September 2014 19:44:11 UTC+2 schrieb Johannes Schönberger:
> Mark, can you check, that this works for you?
>
> https://github.com/scikit-image/scikit-image/pull/1142
>
> Johannes Sch önberger
>
> On Sep 10, 2014, at 1:23 PM, Johannes Sch önberger <js... at demuc.de> wrote:
>
> > Hi Mark,
> >
> > You can do this with `ndimage.map_coordinates`, see https://github.com/scikit-image/scikit-image/blob/master/skimage/transform/_geometric.py#L1134 for an usage example.
> >
> > But we should add this feature, so that `warp` also directly takes the coordinates. I opened a new issue for this: https://github.com/scikit-image/scikit-image/issues/1141
> >
> > Johannes Sch önberger
> >
> > On Sep 10, 2014, at 11:06 AM, Maik Riechert <maik.r... at arcor.de> wrote:
> >
> >> Hi,
> >>
> >> When I want to undistort photographs I use the lensfunpy library (https://pypi.python.org/pypi/lensfunpy) which provides me with a coordinates array of shape (h,w,2), that is for each input pixel it provides the undistorted pixel location. When using OpenCV I can do undistortedImage = cv2.remap(image, undistCoords, None, cv2.INTER_LANCZOS4). I saw that there is the skimage.transform.warp function but I'm not sure how or if I can use that in my case. I would be glad for some directions.
> >>
> >> Thanks
> >> Maik
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups "scikit-image" group.
> >> To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image... at googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "scikit-image" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image... at googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups "scikit-image" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
More information about the scikit-image
mailing list