IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Calcul scientifique Python Discussion :

erreur la reformulation d'une image


Sujet :

Calcul scientifique Python

  1. #1
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2012
    Messages
    67
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2012
    Messages : 67
    Points : 43
    Points
    43
    Par défaut erreur la reformulation d'une image
    j'ai utiliser le code tel qu'il est, mais le
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    id = 0
    imgs_to_process = np.load(output_path+'fullimages_{}.npy'.format(id))
    def resample(image, scan, new_spacing=[1,1,1]):
        # Determine current pixel spacing
        spacing = map(float, ([scan[0].SliceThickness] + scan[0].PixelSpacing))
        spacing = np.array(list(spacing))
     
        resize_factor = spacing / new_spacing
        new_real_shape = image.shape * resize_factor
        new_shape = np.round(new_real_shape)
        real_resize_factor = new_shape / image.shape
        new_spacing = spacing / real_resize_factor
     
        image = scipy.ndimage.interpolation.zoom(image, real_resize_factor)
     
        return image, new_spacing
     
    print "Shape before resampling\t", imgs_to_process.shape
    imgs_after_resamp, spacing = resample(imgs_to_process, patient, [1,1,1])
    print "Shape after resampling\t", imgs_after_resamp.shape


    voila le messge d'erreurs que j'ai
    example.py:136: RuntimeWarning: invalid value encountered in divide
    new_spacing = spacing / real_resize_factor
    Shape after resampling (0, 256, 256)
    Traceback (most recent call last):

  2. #2
    Expert éminent

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 300
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 300
    Points : 6 780
    Points
    6 780
    Par défaut
    Salut,

    Tu ne montres pas l'entièreté du message d'erreur. Pas grand chose d'ailleurs.

    En regard du print "Shape after resampling (0, 256, 256)" il semble, néanmoins, que ton code soit allé jusqu'au bout.

  3. #3
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2012
    Messages
    67
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2012
    Messages : 67
    Points : 43
    Points
    43
    Par défaut
    File "example.py",RuntimeWarning: invalid value encountered in divide
    new_spacing = spacing / real_resize_factor
    Shape after resampling (0, 256, 256)
    Traceback (most recent call last):
    File "example.py", line 278, in <module>
    img = imgs_after_resamp[10]
    IndexError: index 10 is out of bounds for axis 0 with size 0
    tous le message d'erreur

  4. #4
    Expert éminent

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 300
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 300
    Points : 6 780
    Points
    6 780
    Par défaut
    Rien à voir avec le code que tu montres.

    Le message te dis simplement que tu as un dépassement d'index.

    Peut-être en rapport avec "Shape after resampling (0, 256, 256)" où la première valeur de shape est 0.

    Rajoute des print dans ta fonction resample() pour voir comment évoluent les valeurs qui y sont traitées.

  5. #5
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2012
    Messages
    67
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2012
    Messages : 67
    Points : 43
    Points
    43
    Par défaut
    le problème se pose en spacing quand j'ai affiche spacing je trouve que c nan c pour ça que tous e reste ne marche pas
    example.py:101: RuntimeWarning: invalid value encountered in divide
    new_spacing = spacing / real_resize_factor
    ('Shape before resampling:', (192, 128, 128))
    ('Shape after resampling:', (0, 256, 256))
    ('spacing:', array([ nan, 1., 1.]))
    Slice Thickness: 0.000000
    Pixel Spacing (row, col): (2.000000, 2.000000)

  6. #6
    Expert éminent

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 300
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 300
    Points : 6 780
    Points
    6 780
    Par défaut
    Ce print avec nan apparaît après le resample
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    ('Shape after resampling:', (0, 256, 256))
    ('spacing:', array([ nan, 1., 1.]))
    c'est dans la fonction resample() que tu dois mettre les print

  7. #7
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2012
    Messages
    67
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2012
    Messages : 67
    Points : 43
    Points
    43
    Par défaut
    oui c bon pour spacing.
    ('spacing:', array([ 0., 2., 2.], dtype=float32))
    example.py:102: RuntimeWarning: invalid value encountered in divide
    new_spacing = spacing / real_resize_factor
    ('Shape before resampling:', (192, 128, 128))
    ('Shape after resampling:', (0, 256, 256))
    mais pourquoi Shape after resampling: prendre cette valeur (0, 256, 256))

Discussions similaires

  1. Erreur d'ajout d'une image avec Struts 2
    Par franco9 dans le forum Struts 2
    Réponses: 3
    Dernier message: 25/06/2012, 12h26
  2. Erreur de lecture d'une image
    Par soniaIRM dans le forum Images
    Réponses: 2
    Dernier message: 28/03/2012, 15h38
  3. [GD] Erreur à l'affichage d'une image
    Par mimagyc dans le forum Bibliothèques et frameworks
    Réponses: 7
    Dernier message: 01/02/2008, 21h30
  4. VB erreur d'ouverture d'une image trop grande
    Par syldudu dans le forum Access
    Réponses: 2
    Dernier message: 04/01/2008, 16h18
  5. [ImageMagick] Message d'erreur à la génération d'une image jpg
    Par DadaWeb dans le forum Bibliothèques et frameworks
    Réponses: 3
    Dernier message: 06/06/2006, 13h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo