![](https://secure.gravatar.com/avatar/af6c39d6943bd4b0e1fde23161e7bb8c.jpg?s=120&d=mm&r=g)
Hi Almar On Thu, Sep 19, 2013 at 11:36 AM, Almar Klein <almar.klein@gmail.com> wrote:
Skimage also has the Image class (that inherits from np.ndarray), which I believe is mostly there to make the image be shown as an image in IPython notebook. What about taking this idea a bit further? In particular, I am thinking about two things:
1) Allowing extra attributes for the Image class, like "sampling" that specifies the distance between the pixels. This attribute can then be used by algorithms to take anisotropy into account, and visualization toolkits could use it to scale the image in the correct way automatically. This may not seem a very common use case for 2D images, but 3D data is usually not isotropic.
We tried making this the default output of imread, but it caused some problems (e.g. when you slice out a scalar, or sum, you get an Image object out!), so we're back to vanilla arrays. That said, the Image object is still quite useful. The Image class has a dictionary container for adding any type of meta-data you want (e.g., origin, sampling distance, etc.) so I don't know if it is necessary to explicitly specify what those fields should be.
2) Using a PointSet class to represent numpy arrays that are point sets or vector sets. Also such a class can make working with point data much easier, both in internal algorithms, and for the end-user.
An example class can be seen here: https://gist.github.com/almarklein/6620956 it allow things like appending/removing/inserting/popping individual points, and calculating things like normals, angles, distances, etc.
In this case, I see an argument for having such a class, since it behaves differently from a traditional image, and may need to be resampled to a regular grid, etc. The computation of normals, angles, etc. could be be utility functions outside the class (I guess I'm a minimalist when it comes to class design). Regards Stéfan
participants (1)
-
Stéfan van der Walt