From 313cdf2cb4a14722ad3071d347a08f7e3d28ea7c Mon Sep 17 00:00:00 2001 From: Gael varoquaux <gael.varoquaux@normalesup.org> Date: Wed, 1 Dec 2010 20:00:47 +0100 Subject: [PATCH] ENH: dtype is img_to_graph defaults to input dtype --- scikits/learn/feature_extraction/image.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scikits/learn/feature_extraction/image.py b/scikits/learn/feature_extraction/image.py index 027e631e18..cd5fb0865c 100644 --- a/scikits/learn/feature_extraction/image.py +++ b/scikits/learn/feature_extraction/image.py @@ -62,7 +62,7 @@ def _mask_edges_weights(mask, edges, weights): def img_to_graph(img, mask=None, - return_as=sparse.coo_matrix, dtype=np.float): + return_as=sparse.coo_matrix, dtype=None): """ Create a graph of the pixel-to-pixel connections with the gradient of the image as a the edge value. @@ -75,10 +75,13 @@ def img_to_graph(img, mask=None, pixels. return_as: np.ndarray or a sparse matrix class, optional The class to use to build the returned adjacency matrix. - dtype: dtype, optional - The data of the returned sparse matrix + dtype: None or dtype, optional + The data of the returned sparse matrix. By default it is the + dtype of img """ img = np.atleast_3d(img) + if dtype is None: + dtype = img.dtype n_x, n_y, n_z = img.shape edges = _make_edges_3d(n_x, n_y, n_z) weights = _compute_gradient_3d(edges, img) -- GitLab