DICOM medical image processing: Comparison and Analysis of mDCM and DCMTK (1), JPEG lossless compression of DCM images (continued), dicommdcm

Source: Internet
Author: User

DICOM medical image processing: Comparison and Analysis of mDCM and DCMTK (1), JPEG lossless compression of DCM images (continued), dicommdcm
Background:

Through single-step debugging last week, we found the small differences between the Open Source library mDCM and DCMTK in JPEG lossless compression for DICOM images, the DICOM image is successfully compressed in the C ++ and C # environments. However, the problem arises one after another. As the project goes deeper, it is found that the mDCM version that can be implemented in a separate test project has encountered an unexpected error after it is embedded into the entire project, the JPEG lossless compression of DICOM images is not implemented smoothly. Therefore, we need to continue the detailed comparison and analysis of mDCM and DCMTK to find the cause.

Problem Analysis:

After the project log function is enabled, the following information is returned:

No registered codec for transfer syntax! In Dicom. Data. DcmDataset. ChangeTransferSyntax (DicomTransferSyntax newTransferSyntax, DcmCodecParameters parameters .............................. .

According to the log feedback, the registration of JPEG encoder fails. While the encoder part is included in the mDCM open source LibraryDicom. Codec64.dll assembly. Therefore, go to the debug page to check whether the project is loaded successfully.Dicom. Codec64.dll Module.

The first step is to test the standalone project called JpegLossLess last week. call Dicom in cs. codec. dicomCodec. registerCodecs (); enables the program to enter DicomCodec. cs file. The program runs to the static method RegisterCodecs of the static class DicomCodec.

As shown in, RegisterCodecs successfully identifiedDicom. dl assemblyAndDicom. Codec64.dll assembly.

Next, debug the program in a single step to the overall project, and transfer the program from the main framework to the call Dicom. Codec. DicomCodec. RegisterCodecs () that we manually add; function, as shown in:

After several debugging, we found that the JPEG encoder was not successfully registered using the RegisterCodecs function, and only Dicom. dll modules were identified in the 17 programs. By browsing the source code of the DicomCodec. cs file, it is found that the RegisterCodecs function is a static function of the static class DicomCodec, which implements automatic registration of all JPEG encoders. The static class DicomCodec has other similar functions, such as public static void RegisterCodec (DicomTransferSyntax ts, Type type); and public static void RegisterExternalCodecs (string path, string pattern ); the two functions register the decoder for the specified transport semantics and register the decoder for the assembly in the specified path. Because the RegisterCodecs function is not used to automatically load the JPEG decoder, And the DicomCodec64.dll assembly has been added to the project, and the Module window of VS2012 shows that the DicomCodec64.dll assembly has been successfully loaded at the time of debugging. Therefore, we decided to manually load the DicomCodec64.dll Assembly, that is, replace the original Dicom. Codec. DicomCodec. RegisterCodecs (); statement with the following code,

String path = System. IO. Directory. GetCurrentDirectory ();
String pattern = "Dicom. Codec64.dll ";
DicomCodec. RegisterExternalCodecs (path, pattern );

At this moment, the single-step debugging shows that the registration of the JPEG decoder in the DicomCodec64.dll program has been successful, and the integration of the DICOM image JPEG compression function with the overall project has been completed.

Summary: 1) Can the GetReferencedAssemblies function return all referenced assemblies in the project?

By comparingAutomaticAndManualIn the end, the GetExportedTypes function is used to complete registration. The specific code is Type [] types = asm. getExportedTypes (); to extract the corresponding decoder. The only difference is that AssemblyName [] referenced = main. getReferencedAssemblies (); extracts the referenced Assembly of this module, while manual registration uses the Assembly. is the GetReferencedAssemblies function a problem when the LoadFile function loads the specified Assembly file manually? Can the GetReferencedAssemblies function return all referenced assembly in our project?

Search for the functions of the GetReferencedAssemblies function on MSDN. The descriptions are as follows:GetsAssemblyNameObjects for all the assemblies referenced by this assembly.

At first glance, it seems that this function can return the names of all loaded assemblies in our project. But after careful analysis, what is mentioned in the description is"This assembly", Here this should refer to the Assembly that calls the RetReferencedAssemblies function. Therefore, this function should obtain all the Assembly referenced by the current module, it is not the reference assembly of the entire project that we initially thought. After a long search, finally in a stackoverflow blog (http://stackoverflow.com/questions/3971793/what-when-assembly-getreferencedassemblies-returns-exe-dependency) found the relevant description of "extract all the dependent assembly of the project", the author not only gives the implementation method, it also gives the reason why the GetReferencedAssemblies function does not return all referenced assembly in the project (http://msdn.microsoft.com/en-us/magazine/cc163641.aspx ). Here, we will briefly summarize it and borrow the original author's diagram:

As shown in, if we call the GetReferencedAssemblies function in module A, the function should returnThis --Assembly B, C, and D referenced (directly applied. However, as shown on the left, assembly C and D reference other assemblies respectively, so we did not directly obtain all the assemblies in the project. Therefore, the Dicom. Codec64 assembly we need is not returned smoothly during automatic loading.

Speaking of this, I thinkExtract all referenced assembly of the projectThe simplest method is that we can call the first return value of GetReferencedAssemblies recursively, so we can naturally get all the reference assembly A-J. However, in the blog post, the author extracts all referenced assembly from the right, because recursion affects program performance, especially when many program modules exist. In short, we use the"Forward TraversalTo extract all referenced assembly. The specific code can be downloaded from the reference blog.

2) Static Class C # And Singleton Design Mode

After comparing the source code registered by the mDCM and DCMTK open-source libraries for JPEG decoders, we found that in the DCMTK open-source library completed with C ++, the DcmCodecList class in the Singleton design mode is used to register various JPEG decoders. The mDCM open source library written in C # uses the static class public static DicomCodec of C. These two methods can achieve the same function. Since the first change from C ++ to C #, the difference between the two is not very clear, so I searched for it, only some important parts are extracted and pasted in the blog for future reference.

【Abstract】 1 ]:Http://bbs.csdn.net/topics/370008452

Apart from cross-assembly boundary issues, there is no essential difference between the static class and a single piece that imitates GoF C ++. I am interested in discussing whether the two have achieved the same effect while meeting the same motivation. My personal opinion is that static classes have a simple and elegant side. In fact, in terms of Java and C #, there is a problem with the GoF design pattern. This is the classic Double Lock Check problem (see CLR via C #).

Roughly speaking, in C #4, these patterns disappear: single piece (static class), Policy (delegate and Lambda), observer (event), decoration (Extension Method) factory (partially implemented by reflection), proxy (Expression Tree and dynamic class), iterator (yield return syntax), etc. If you follow GoF implementation to do this, instead, you have gone far.

Finally, not only singleton, but a general view of design patterns is that with the development of programming languages, the implementation of all design patterns will die out, and the ideas will be preserved. The essence of the design model can also be said to modify the defects of the language. It is an elegant language that does not require a design model. (This idea was put forward by one of my college students, he is also an expert in the Ruby community ).

【Abstract】 2 ]:Http://www.cnblogs.com/utopia/archive/2010/03/02/1676390.html

The semantics of a static class is a globally unique code segment, and the semantics of a single piece is a globally unique object instance;

The semantics is completely different. We can't say that the modifier is "globally unique", so we can put a comparison;

If so, we don't have to repeat all the public modifier items;

In addition, if you want to study object design, leave the code aside. Object design is an expression of philosophy and world view.

It is the essence of Object design to restore and express the real things with concepts. Code is a tool that reflects the conceptual model in your mind.

【Abstract ]:Http://blog.csdn.net/lyrebing/article/details/1902235

The purpose of Singleton mode is to provide a unique instance of the class in the program and only provide a unique access point. Static instances are not required. Only one global function is provided. The use of a single instance can inherit and implement interfaces, but the static class cannot. The static method cannot be an instance field in the response class, because the static method is not accessed through an instance. The method in the single instance can access the instance field in the unique instance. After a static method is executed, all objects created by it are released. The methods in the singleton can be retained. Static fields only provide global functions. You can share the same memory location. The field in the access ticket is a field in the unique instance of the class. You can only access the field of this instance.

 

By zssure@163.com

Time: 2014-08-17


Does anyone know how to use VC ++ and DCMTK to display DICOM medical images?

Question added: Are there any tutorials or books in this area? I have read only a small amount of online materials. I can't do it. You can help me. Good guys are safe for life. Heat
 
Who will perform dicom compression ??

Dcmtk352 or dcmtk354?
Typedef enum {
EXS_Unknown =-1,
EXS_LittleEndianImplicit = 0,
EXS_BigEndianImplicit = 1,
EXS_LittleEndianExplicit = 2,
EXS_BigEndianExplicit = 3,
Exs_export process1transfersyntax = 4,
Exs_export process2_4transfersyntax = 5,
Exs_effecprocess3_5transfersyntax = 6,
Exs_export process6_8transfersyntax = 7,
Exs_export process7_9transfersyntax = 8,
Exs_export process10_12transfersyntax = 9,
Exs_export process11_13transfersyntax = 10,
Exs_export process14transfersyntax = 11,
Exs_export process15transfersyntax = 12,
Exs_export process16_18transfersyntax = 13,
Exs_export process17_19transfersyntax = 14,
Exs_export process20_22transfersyntax = 15,
Exs_export process21_23transfersyntax = 16,
Exs_export process24_26transfersyntax = 17,
Exs_export process25_27transfersyntax = 18,
Exs_export process28transfersyntax = 19,
Exs_export process29transfersyntax = 20,
Exs_export process14sv1transfersyntax = 21,
EXS_RLELossless = 22,
EXS_JPEGLSLossless = 23,
EXS_JPEGLSLossy = 24,
EXS_DeflatedLittleEndianExplicit = 25,
Exs_00002000losslessonly = 26,
Exs_mpeg-4 = 27
} E_TransferSyntax;

We used EXS_JPEGProcess14SV1TransferSyntax and something. You 'd better find dcmtk information.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.