Image format Analyze 7.5

inkognitodz Messages postés 13 Date d'inscription mardi 19 mai 2009 Statut Membre Dernière intervention 26 juin 2012 - 25 juin 2012 à 20:01
inkognitodz Messages postés 13 Date d'inscription mardi 19 mai 2009 Statut Membre Dernière intervention 26 juin 2012 - 26 juin 2012 à 13:54
Pourriez-vous m'aider Je n'arrive pas à lire une image IRM de format Analyze 7.5 (comprenant deux fichiers : header *.hdr et image *.img) sous C++ Builder.

5 réponses

BunoCS Messages postés 15476 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 3 mai 2024 103
26 juin 2012 à 10:49
Hello,
Voici les specs du format Analyse 7.5


@+
Buno, Admin CS
L'urgent est fait, l'impossible est en cours. Pour les miracles, prévoir un délai...
0
inkognitodz Messages postés 13 Date d'inscription mardi 19 mai 2009 Statut Membre Dernière intervention 26 juin 2012
26 juin 2012 à 11:57
mmmmmmm ok !!!

voici ce que j'ai trouvé :


void __fastcall TForm1::Button1Click(TObject *Sender)
{

TOpenDialog* dlgOuvrir = new TOpenDialog(this);
dlgOuvrir->Title = "Ouvrir l'image IRM 3D";
dlgOuvrir->DefaultExt= "*.hdr" ;
dlgOuvrir->FileName= "*.hdr" ;

if (dlgOuvrir->Execute())
{
    String strFichierHDR = dlgOuvrir->FileName;

//lecture fichier header
    dsr hdr;
    FILE *fp;
    if((fp fopen(strFichierHDR.c_str(), "r")) NULL)
    {
        ShowMessage("le fichier n'existe pas !!");
    }
    else
    {
        fread(&hdr, 1,sizeof(dsr), fp);
fclose(fp);
    }

//lecture fichier image
    FILE *id;
    short buf[1];
    short mat3[100][100][100];
    id=fopen(strFichierIMG.c_str(),"rb");
    for (int k=0;k<100;k++)
       for (int i=0;i<100;i++)
           for (int j=0;j<100;j++)
           {
               fread(buf,1,1,id);
               mat3[i][j][k] = buf[1];
           }
    fclose(id);
 }

}


mais je n'arrive pas à lire l'image !!!! blocage !
0
inkognitodz Messages postés 13 Date d'inscription mardi 19 mai 2009 Statut Membre Dernière intervention 26 juin 2012
26 juin 2012 à 12:00
plutôt ça
void __fastcall TForm1::Button1Click(TObject *Sender)
{

TOpenDialog* dlgOuvrir = new TOpenDialog(this);
dlgOuvrir->Title = "Ouvrir l'image IRM 3D";
dlgOuvrir->DefaultExt= "*.hdr" ;
dlgOuvrir->FileName= "*.hdr" ;

if (dlgOuvrir->Execute())
{
    String strFichierHDR = dlgOuvrir->FileName;
    String strFichierIMG = ChangeFileExt(dlgOuvrir->FileName, ".img");

//lecture fichier header
    dsr hdr;
    FILE *fp;
    if((fp fopen(strFichierHDR.c_str(), "r")) NULL)
    {
        ShowMessage("le fichier n'exist pas !!");
    }
    else
    {
        //Form1->Cursor =crAppStart ;
        fread(&hdr, 1,sizeof(dsr), fp);
fclose(fp);
    }
//lecture fichier image
    FILE *id;
    short buf[1];
    short mat3[100][100][100];
    id=fopen(strFichierIMG.c_str(),"rb");
    for (int k=0;k<cp;k++)
       for (int i=0;i<h;i++)
           for (int j=0;j<w;j++)
           {
               fread(buf,1,1,id);
               mat3[i][j][k] = buf[1];
           }
    fclose(id);
 }

}
//---------------------------------------------------------------------------
0
inkognitodz Messages postés 13 Date d'inscription mardi 19 mai 2009 Statut Membre Dernière intervention 26 juin 2012
26 juin 2012 à 12:02
supposons cp=h=w=100
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
inkognitodz Messages postés 13 Date d'inscription mardi 19 mai 2009 Statut Membre Dernière intervention 26 juin 2012
26 juin 2012 à 13:54
Je viens de modifier le code mais je n'arrive toujours pas à afficher l'image... résultat : image unie !

//---------------------------------------------------------------------------

#include <vcl.h>
#include <stdio.h>


#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

short mat3[300][300][300];

struct header_key
{                               /* off + size */
    int sizeof_hdr;             /* 0 + 4 */
    char data_type[10];         /* 4 + 10 */
    char db_name[18];           /* 14 + 18 */
    int extents;                /* 32 + 4 */
    short int session_error;    /* 36 + 2 */
    char regular;               /* 38 + 1 */
    char hkey_un0;              /* 39 + 1 */
};
 
struct image_dimension
{                       /* off + size */
    short int dim[8];   /* 0 + 16 */
    short int unused8;  /* 16 + 2 */
    short int unused9;  /* 18 + 2 */
    short int unused10; /* 20 + 2 */
    short int unused11; /* 22 + 2 */
    short int unused12; /* 24 + 2 */
    short int unused13; /* 26 + 2 */
    short int unused14; /* 28 + 2 */
    short int datatype; /* 30 + 2 */
    short int bitpix;   /* 32 + 2 */
    short int dim_un0;  /* 34 + 2 */
    float pixdim[8];    /* 36 + 32 */
    float vox_offset;   /* 68 + 4 */
    float funused1;     /* 72 + 4 */
    float funused2;     /* 76 + 4 */
    float funused3;     /* 80 + 4 */
    float cal_max;      /* 84 + 4 */
    float cal_min;      /* 88 + 4 */
    float compressed;   /* 92 + 4 */
    float verified;     /* 96 + 4 */
    int glmax,glmin;    /* 100 + 8 */
};
 
struct data_history
{                           /* off + size */
    char descrip[80];       /* 0 + 80 */
    char aux_file[24];      /* 80 + 24 */
    char orient;            /* 104 + 1 */
    char originator[10];    /* 105 + 10 */
    char generated[10];     /* 115 + 10 */
    char scannum[10];       /* 125 + 10 */
    char patient_id[10];    /* 135 + 10 */
    char exp_date[10];      /* 145 + 10 */
    char exp_time[10];      /* 155 + 10 */
    char hist_un0[3];       /* 165 + 3 */
    int views;              /* 168 + 4 */
    int vols_added;         /* 172 + 4 */
    int start_field;        /* 176 + 4 */
    int field_skip;         /* 180 + 4 */
    int omax, omin;         /* 184 + 8 */
    int smax, smin;         /* 192 + 8 */
};
 
struct dsr
{
    struct header_key hk;           /* 0 + 40 */
    struct image_dimension dime;    /* 40 + 108 */
    struct data_history hist;       /* 148 + 200 */
};


//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{

TOpenDialog* dlgOuvrir = new TOpenDialog(this);
dlgOuvrir->Title = "Ouvrir l'image IRM 3D";
dlgOuvrir->DefaultExt= "*.hdr" ;
dlgOuvrir->FileName= "*.hdr" ;

if (dlgOuvrir->Execute())
{
    String strFichierHDR = dlgOuvrir->FileName;
    String strFichierIMG = ChangeFileExt(dlgOuvrir->FileName, ".img");

//lecture fichier header
    dsr hdr;
    FILE *fp;
    if((fp fopen(strFichierHDR.c_str(), "r")) NULL)
    {
        ShowMessage("le fichier n'existe pas !!");
    }
    else
    {
        Form1->Cursor =crAppStart ;
        fread(&hdr, 1,sizeof(dsr), fp);
fclose(fp);
    }
//lecture fichier image
    FILE *id;
    short buf[1];

    id=fopen(strFichierIMG.c_str(),"rb");
    for (int i=0;i<218;i++)
       for (int j=0;j<182;j++)
           for (int k=0;k<218;k++)
           {
                fread(buf,1,1,id);
                mat3[i][j][k] = buf[1];

           }
    fclose(id);
 }

//afficher une coupe
    for (int i=0;i<218;i++)
      for (int j=0;j<182;j++)
          {Image1->Canvas->Pixels[j][i]=RGB(mat3[i][j][73],0,0); }

Form1->Cursor =crDefault ;
}
//---------------------------------------------------------------------------
0
Rejoignez-nous