tinydicom + rawprocessor lesson #2
Comments Off on tinydicom + rawprocessor lesson #2
Now it’s time to next step for using my open sources, And here I like to introduce how loads DCM and what it contains inside tags. Just read my example code to read DICOM tags from DCM file, it should help what inside.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
#ifdef __APPLE__ #include <sys/uio.h> #elif _WIN32 #include <io.h> #else #include <sys/io.h> #endif #include <cstdio> #include <cstdlib> // -- std --- #include <string> #include <vector> using namespace std; // -- other headers -- #include "libdcm.h" //////////////////////////////////////////////////////////////////////////////// #define MADE_DATE "2017-04-18-0" //////////////////////////////////////////////////////////////////////////////// const char sampledcm[] = "SIMFIT.dcm"; //////////////////////////////////////////////////////////////////////////////// void testDCM() { printf( "#TEST: Loading DCM #\n" ); printf( "Loading DCM file : %s ... ", sampledcm ); if ( OpenDCM( sampledcm ) == true ) { printf( "Ok.\n" ); printf( "Check elements : " ); int elemsz = GetElementCount(); printf( "%d elements found.\n", elemsz ); if ( elemsz > 0 ) { for( int cnt=0; cnt<elemsz; cnt++ ) { DCMTagElement* elem = NULL; if ( GetElement( cnt, &elem ) > 0 ) { printf( "\t[%03d : %c%c] ID = %04X:%04X , size = %d bytes \n", cnt + 1, elem->VRtype[0], elem->VRtype[1], ( elem->id & 0xFFFF0000 ) >> 16, elem->id & 0x0000FFFF, elem->size ); delete elem; } } } CloseDCM(); } } //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// int main( int argc, char** argv ) { printf( "librawprocessor + libtinydicom, examples : %s\n", MADE_DATE); printf( "(C)2017, Raph.K.\n"); testDCM(); return 0; } |
It may compiles with libtinydicom.a linkage… Read more »