Salome HOME
Merge 'master' branch into 'V9_dev' branch.
[modules/med.git] / doc / tut / medcoupling / testmed_lena.py
index 3b281aa532500eb515d0dbe2f570e947006a3cc4..3849d0f8217ab6e5b9f3f4aba0db79f37309c4a6 100755 (executable)
@@ -1,5 +1,4 @@
-#!/usr/bin/env python
-#  -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
 # Copyright (C) 2011-2016  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
@@ -24,6 +23,8 @@
 # as a field in a med file.
 # (gboulant - 27/06/2011)
 
+import os
+
 import MEDCoupling as MC
 import MEDLoader as ML
 
@@ -37,7 +38,8 @@ import scipy, numpy
 #image = scipy.lena()
 # We could either read a real image using the PIL python package.
 from scipy.misc import pilutil
-image = pilutil.imread("images/avatar.png",True)
+CURDIR = os.path.dirname(__file__)
+image = pilutil.imread(os.path.join(CURDIR, "images", "avatar.png"),True)
 
 
 #from PIL import Image
@@ -45,10 +47,10 @@ image = pilutil.imread("images/avatar.png",True)
 #im=Image.open("images/lena.png")
 #image=pilutil.fromimage(im,True)
 #image=numpy.asarray(im)
-#print image
+# print(image)
 
 dim  = len(image.shape)
-print "Image space dimension = %d"%dim
+print("Image space dimension = %d"%dim)
 sizeX = image.shape[1]
 sizeY = image.shape[0]
 
@@ -60,7 +62,7 @@ sizeY = image.shape[0]
 # double as required by the MEDCoupling field specification.
 import numpy
 imageDataNArray       = image.reshape(1,sizeX*sizeY)[0]
-print imageDataNArray
+print(imageDataNArray)
 
 imageDataNArrayDouble = numpy.array(imageDataNArray, dtype='float64')
 imageDataArrayDouble  = list(imageDataNArrayDouble)
@@ -95,7 +97,7 @@ coordsY=MC.DataArrayDouble.New()
 coordsY.setValues(arrY,nbNodesY,1)
 
 cmesh.setCoords(coordsX,coordsY)
-print "Imagem mesh dimension: %d"%cmesh.getSpaceDimension()
+print("Imagem mesh dimension: %d"%cmesh.getSpaceDimension())
 
 # WARN: In the current state of development of MEDLoader, only
 # unstructured meshes are supported for writing function in med