[python-arrayfire] 150/250: FEAT: Adding native image loading and saving from arrayfire 3.2

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository python-arrayfire.

commit c0423b76916ae5acea78d4caeb162093d248c65c
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Tue Dec 8 18:27:46 2015 -0500

    FEAT: Adding native image loading and saving from arrayfire 3.2
---
 arrayfire/image.py | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/arrayfire/image.py b/arrayfire/image.py
index c46cc3a..49cc76d 100644
--- a/arrayfire/image.py
+++ b/arrayfire/image.py
@@ -78,6 +78,44 @@ def save_image(image, file_name):
     safe_call(backend.get().af_save_image(ct.c_char_p(file_name.encode('ascii')), image.arr))
     return image
 
+
+def load_image_native(file_name):
+    """
+    Load an image on the disk as an array in native format.
+
+    Parameters
+    ----------
+    file_name: str
+          - Full path of the file name on disk.
+
+    Returns
+    -------
+    image - af.Array
+            A 2 dimensional (1 channel) or 3 dimensional (3 or 4 channel) array containing the image.
+
+    """
+    assert(os.path.isfile(file_name))
+    image = Array()
+    safe_call(backend.get().af_load_image_native(ct.pointer(image.arr),
+                                                 ct.c_char_p(file_name.encode('ascii'))))
+    return image
+
+def save_image_native(image, file_name):
+    """
+    Save an array as an image on the disk in native format.
+
+    Parameters
+    ----------
+    image : af.Array
+          - A 2 or 3 dimensional arrayfire array representing an image.
+
+    file_name: str
+          - Full path of the file name on the disk.
+    """
+    assert(isinstance(file_name, str))
+    safe_call(backend.get().af_save_image_native(ct.c_char_p(file_name.encode('ascii')), image.arr))
+    return image
+
 def resize(image, scale=None, odim0=None, odim1=None, method=INTERP.NEAREST):
     """
     Resize an image.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-arrayfire.git



More information about the debian-science-commits mailing list