Summary of the invention
The invention provides a kind of method that embeds the DICOM image in the audit report of audit report editing machine, to solve prior art when writing audit report, need to change to medical image could generate audit report and print, and the technical matters of can not the audit report contents OK when printing preserving.
The present invention adopts following technical scheme to realize: a kind of method that embeds the DICOM medical image in audit report, and it comprises step:
In A, check DICOM medical image and audit report editing machine, the consistance of audit report, if both have consistance, change step B over to;
B, for the audit report editing machine creates image buffers pond object, load the DICOM medical image to the object of image buffers pond;
C, create the document storage object ImageNode of a medical image for the audit report editing machine, and ImageNode is inserted in the doubly linked list of expression audit report editing machine storage organization;
The document of D, establishment DICOM medical image shows object, the DICOM medical image is carried out typesetting process;
E, convert the DICOM medical image to the DIB bitmap, show the DIB bitmap when showing audit report by the audit report editing machine.
Wherein, described steps A be checking DICOM medical image whether with audit report in patient information be consistent.
Wherein, the step that loads the DICOM medical image in described step B specifically comprises: judge whether this DICOM medical image has existed in the object of image buffers pond, if, directly obtain the pointer of this DICOM medical image from the object of image buffers pond, otherwise this DICOM medical image is loaded into the buffer memory of audit report editing machine, and the pointer that will change the DICOM medical image leaves in the object of image buffers pond in.
Wherein, in described step B, the step of loading DICOM medical image specifically also comprises:
When closing this DICOM medical image, judge whether the reference count of the pointer of this DICOM medical image is 0, if reference count is not 0, changes next step over to, otherwise withdraw from;
Judge that reference count corresponding to DICOM medical image that cushions in the object of image buffers pond is whether 0 number has surpassed maximal value, if so, deletes this DICOM medical image, otherwise the reference count of this DICOM medical image is subtracted 1.
Wherein, the document storage object ImageNode of described medical image gets the data of DICOM medical image from the object of image buffers pond according to the filename of DICOM medical image.
Wherein, described step D specifically comprises:
When ImageNode being inserted into the doubly linked list of expression audit report editing machine storage organization, responded the variation of the doubly linked list of audit report editing machine storage organization by the paragraph layout object;
The document that creates the DICOM medical image shows object, and the document shows that object has comprised the filename of DICOM medical image;
According to the position of ImageNode in the doubly linked list of audit report editing machine storage organization, the document of medical image is shown that object is inserted in the doubly linked list that expression shows object by the paragraph layout object;
The paragraph layout object will represent to show that all documents in the doubly linked list of object show that objects are assigned to corresponding line and show.
Wherein, described step e specifically comprises:
According to the filename of the DICOM medical image that comprises in ImageNode, get the data of this DICOM medical image from the object of image buffers pond by this document name, and with these data encapsulation in the image object;
The image object is converted to the DIB bitmap, sets up the DIB bitmap of a storage DICOM medical image in the buffer memory of audit report editing machine;
Pixel data in rectangular area in the DIB bitmap is copied to the target rectangle of appointment in audit report.
Wherein, described audit report editing machine shows that the step of audit report comprises:
Traversal shows all pages of audit report in the audit report editing machine;
When showing every one page of audit report, traversal shows all row in page, and when showing every delegation, in the traversal display line, each document shows object.
Wherein, described method also comprises step: F, the medical image of DIB bitmap format is carried out the adjustment of window width and window level in audit report.
Wherein, described step F specifically comprises:
The document of medical image shows object response mouse click event, current state that document shows object is set is selected state;
When using mousebutton to pull on medical image, the all documents of audit report editing machine traversal current page show object, if the document of medical image shows the viewing area of object and has comprised mouse position, the document of this medical image shows that object response right button pulls event, window width and window level value to medical image is adjusted, by regenerating the DIB bitmap according to the window width and window level value and showing.
Compared with prior art, the present invention has following beneficial effect:
The invention provides a kind of method that embeds the DICOM image in the audit report editing machine, overcome prior art when writing audit report, need to change to medical image could generate audit report and print, and the defective of can not the audit report contents OK when printing preserving.The present invention can verify the consistance of medical image and report content, can also carry out the adjustment of window width and window level to medical image in the audit report editing machine, thereby facilitate the user.
Embodiment
The invention provides and embed DICOM medical image (following but also be called for short " DICOM image " or " DICOM picture ") in the audit report of a kind of audit report editing machine (following not only referred to as " editing machine ") and be the method for Presentation Function, overcome prior art when writing audit report, need to change to medical image could generate audit report and print, and the defective of can not the audit report contents OK when printing preserving.
For understanding the present invention, first to the Information encapsulation form of DICOM file, extract image information, the medical science characteristic of DICOM image, DICOM image in the DICOM file and how to be converted to the principle that embeds the DICOM image in DIB bitmap, editing machine etc. and to introduce one by one.
, the DICOM medical image definition, and the Information encapsulation form of DICOM file
DICOM(Digital Imaging and Communications in Medicine, digitized video and communication standard) be to unite initiation by ACR (ACR) and national electrical manufacturers association (NEMA) at first, a kind of international standard of jointly participating and draw and set up by some other standardization body (as 251 technical committees of European Committee for Standardization etc.) in the world afterwards, be mainly used in the exchange of standard medical image and relevant information thereof, for manufacturer and the user of medical imaging device provides interface standard and interaction protocol etc.The DICOM medical image is namely the digital medical image that meets this standard.
According to the Information encapsulation form of DICOM file (image), extract the image information in the DICOM file.That is to say, the DICOM file is decoded, extract the information such as image parameter, view data.
The DICOM file layout is the industrial standard of digital medical image now, and the DICOM file can only be by the software transfer of special use and output, and its expansion is called " .dcm ".The DICOM file be one about the data set of imformosome example, four layers of information such as patient, inspection, sequence, image have been comprised, also just say, not only store medical image in the DICOM file, but also stored name, sex, medical history, inspection hospital, supervision time, imaging device model, imaging parameters of a large amount of other medical informations of sufferer such as sufferer etc.The DICOM file layout is as shown below, is comprised of file header and data set.File header is made of Preamble and Prefix; Wherein the length of Preamble is 128 bytes, usually is made as " 0 "; Prefix is that length is 4 byte character strings " DICM ".The image information of sufferer and other medical information all are encapsulated in the data centralization that is comprised of the mass data element.Each data element is comprised of label, value description (type), value length, codomain four parts again.
, extract the image information in the DICOM file
In order to extract the image information in the DICOM file, at first to extract the data centralization label and be the data element of (0002,0010) expression transmission syntax.A UID value (as 1.2.840.10008.1.2 etc.) is provided in this data element, and this UID value has illustrated coded system that in this DICOM file, data set adopts and the compress mode of view data.
According to the coded system of file, adopt the data element codomain of corresponding label relevant with image information below corresponding coding/decoding method extraction:
The number of components of (0028,0002) each pixel;
(0028,0004) luminosity description (as gray-scale map, coloured picture etc.);
The line number of (0028,0010) image;
The columns of (0028,0011) image;
The figure place that (0028,0100) each pixel is distributed;
The figure place of (0028,0101) each pixel value storage;
The most significant digit of (0028,0102) pixel;
Whether (0028,0103) pixel value contains symbol;
Whether (0028,0300) the control chart image quality;
Whether (0028,0301) embeds note in image;
(0028,1040) picture element density relation;
(0028,1041) picture element density relational symbol;
(0028,1050) window position;
(0028,1051) window width;
(0028,1052) linear intercept;
(0028,1053) linear gradient;
(0028,1054) linear-type;
(0028,1055) window position window width note;
(0028,2110) Image Lossy Compression type;
(7FE0,0010) pixel data (pixelvalue);
According to the compress mode that this DICOM medical image adopts, call decompression module corresponding in dicom standard pixel data is carried out decompression processing, just can intactly extract the image information in the DICOM file.
After having extracted the pixel data of image, also need it is carried out the once linear conversion actual pixel value that is only image that obtains.The formula of linear transformation is:
Actual pixel value=pixel data value x linear gradient+linear intercept.
, the DICOM image the medical science characteristic
In most of the cases, the linear gradient of DICOM image is 1, linear intercept is 0, that is to say that actual pixel value is exactly that label is the pixel data value in the data element of (7FE0,0010).
In most of the cases, the DICOM medical image is all to show that in GTG figure mode the raw data that its pixel data produces when being exactly in fact the equipment imaging is generally the CT value.The CT value namely represents the pad value after x-ray passes tissue and is absorbed.the scope of the CT value of one secondary 12 DICOM images is 4096, be that the gray level that machine can be identified is 4096, but in fact the gray level that human eye can be identified is no more than 256(, human eye can be differentiated gray level and be far from 256, such as human eye be can't differentiate gray-scale value be 100 and gray-scale value be 101 difference), if directly medical image is shown with 256 grades of gray-scale maps, can't see the detailed information between the tissue in the DICOM image, can't satisfy the requirement of medical diagnosis, so the concept that needs to introduce window position and window width comes substep dynamically to show medical information complete in image.
Window position, the i.e. center of selected digital image CT value in image display process.In the diagnosis procedure for displaying, for the different tissue of human body, different organ, the value of window position is selected different, and the selection of window place value is comparatively fixing, as bone window position, liver window position etc.
Window width, namely in image, the selected CT value that shows is interval.If selected maximum CT value is MAXct, selected minimum CT value is MINct:
For the CT value〉pixel of MAXct is shown as black (or white) without exception, is shown as without exception white (or black) for the pixel of CT value<MINct.For the CT value that is in the window width scope, we are mapped to the GTG space of 256 grades by linear or nonlinear conversion (generalized case is linear, and what the dicom standard acquiescence was default is linear transformation) with the CT value in this window width scope.
For nonlinear situation, in the DICOM file, label is (0028,3010) data element can provide a look-up table (Look-Up-Table, LUT) to shine upon this transformational relation, and the information that we only need to extract and contrast look-up table is carried out pixel value conversion and got final product.For linear transformation, namely label is that the data element values of (0028,3010) is 0 o'clock (or the DICOM file does not have this data element), is calculated as follows the gray-scale value of each pixel in 256 grades of gray-scale maps:
By introducing the concept of window position, window width, each DICOM image that shows only highlights the histoorgan variations in detail of a certain type.Can be according to doctor's different needs, adjust the value of window position window width, thereby same DICOM image is done the demonstration of outstanding different emphasis features, reach substep and extract the purpose that comprises other abundant medical informations in the DICOM image.
, the DICOM image transitions is the principle of DIB bitmap
DIB(Device-Independent Bitmap) bitmap is the bitmap of another form, and it has solved bitmap fully and has transmitted problem, and the machine of any operation Windows operating system can be processed the DIB bitmap.The DIB bitmap document form take suffix as BMP usually is retained in disk, after the BMP file reads out from disk file, is usually changed into the GDI bitmap, but program can directly utilize the DIB form to carry out work necessary the time.
At first, extract raw image data and correlation parameter in the DICOM image, according to the window position window width (or LUT table) of indicating in the DICOM file, raw pixel data is carried out linear transformation, be converted into each pixel displayed value corresponding in 256 grades of gray spaces.
Then, create the storage space of a storage DIB formatted file in internal memory, the information (as picture traverse, height etc.) of image correlation in the DICOM file is stored in the DIB call format in the file header in this space, then sets up 256 grades of greyscale color tables of a DIB form.In the data image district of DIB form, will be through the pixel displayed value that is converted to, according to from image row pixel last, the displayed value of sequential storage pixel from left to right, whether the columns that calculates original image is 4 multiple, if be not 4 multiple, the end benefit value of every delegation is 0 byte, it is 4 multiple that columns is mended, and then begins the storage of row pixel second from the bottom, until finish.
This shows, the pixel data in the DIB bitmap is not the raw data in the DICOM image, but advances corresponding displayed value in 256 grades of later gray spaces of window position window width adjustment.
, embed the principle of DICOM image in editing machine
For the content of user's input, editing machine will be stored with certain data structure, and we are referred to as the document storage object.Wherein, the data structure of document storage object as shown in Figure 1.The document storage object comprises the document storage object (TextNode) of text, the document storage object (BlockNode) of paragraph, the contents such as document storage object (ImageNode) of image.The storage organization of doubly linked list has been adopted in the realization of various document storage objects in editing machine.
After user input text, at first we create the storage object of text, then according to position embedded text storage object in this doubly linked list of input.
Editing machine need to be that each paragraph creates corresponding typesetting object, is used for that the text of paragraph and image etc. are carried out typesetting and processes.The typesetting processing is mainly the document storage organization establishment document demonstration object for editing machine, and distributes coordinate for these documents show, affiliated row is set.These show that object is also to store in the mode of doubly linked list.
Specifically, the principle that embeds the DICOM image in the audit report editing machine is as follows: to the processing of DICOM image with to common text-processing, principle is similar.Editing machine is that the storage object of DICOM image creation needs to get all raw data of DICOM image, so that the processing in later stage; During typesetting, according to the storage object of DICOM image in document, create the corresponding object that shows, typesetting need to be considered the wide and high of DICOM image, calculates the height that it is expert at, and the position of line feed; During demonstration, DICOM shows only responsible drafting to oneself of object, and it is the DIB bitmap that the method for drafting is about to the DICOM image transitions, then is plotted on the interface.
In conjunction with shown in Figure 2, the present invention embeds the DICOM medical image in the audit report of audit report editing machine method comprises following performing step:
Step S1, the consistance of audit report in DICOM medical image to be embedded and audit report editing machine is verified.
Embed medical image in audit report, the DICOM medical image that should verify embedding whether with audit report in patient information be consistent.The LDIMSESet class has encapsulated the processing to the DICOM file, at first by constructed fuction LDCMFileSet (Stream ﹠amp; In) import DICOM document flow structure LDIMSESet object into, obtain element by call function GetElement according to the TAG value, element information is encapsulated in the LdicomElement object.The patient information that can import in editing machine by value and the report of contrast LdicomElement, whether checking DICOM medical image belongs to same patient information in the audit report content, if, DICOM medical image and audit report content have consistance, change next step S2 over to, otherwise withdraw from.
Step S2, audit report editing machine load the DICOM medical image.
The audit report editing machine reads in the DICOM file, constructs the LDIMSESet object.The Image class has encapsulated the processing to the DICOM medical image, and Image can pass through load (LDIMSESet ﹠amp; Data) obtain view data.
For the audit report editing machine creates image buffers pond imagePool object, be used for depositing the DICOM medical image.Wherein, the design of imagePool class as shown in Figure 3.
ImagePool has realized the buffering of image.Judge first whether this medical image has existed in imagePool before loading the DICOM medical image files, if, directly obtain the pointer of this DICOM medical image from imagePool, otherwise the DICOM medical image is loaded into the buffer memory of audit report editing machine, and the pointer of DICOM medical image is left in image buffers pond object (imagePool).When closing the DICOM medical image, whether the reference count that judges the pointer of this DICOM medical image is 0, be not 0 as reference count, the medical image reference count that judges again imagePool buffering is whether 0 number has surpassed maximal value, if reference count has surpassed maximal value, this DICOM medical image of deletion from imagePool, otherwise just the reference count of this DICOM medical image is subtracted 1.So just reduced the loading repeatedly to same DICOM medical image.
The document storage object of step S3, establishment audit report editing machine.
When the user need to insert a DICOM medical image in the audit report editing machine, at first need to create the document storage object ImageNode(of a medical image as shown in Figure 2), comprised the filename (fileName) of DICOM medical image, the wide high attribute information (attributes) of image etc. inside the document storage object of this medical image, we can get the complete data in audit report editing machine buffer memory of DICOM medical image from imagePool by this document name.Then ImageNode is inserted in the doubly linked list (as shown in Figure 1) that represents the editing machine storage organization and goes.
Step S4, the DICOM medical image is carried out typesetting process.
After inserting the ImageNode of a medical image in the doubly linked list of expression document storage object, the variation of paragraph layout object reference onchange response document storage object, the document that creates the DICOM medical image shows object ImageShowObject, this document shows the filename that has comprised the DICOM medical image in object, and we can get DICOM medical image complete data in audit report editing machine buffer memory from imagePool by this document name.The paragraph layout object is according to the position of ImageNode in the doubly linked list of audit report editing machine storage organization, and the document of medical image is shown that object ImageShowObject is inserted in the doubly linked list that expression shows object.
Then the paragraph layout object shows that with all documents wherein object is assigned to corresponding row: at first paragraph layout object traversal document shows the doubly linked list of object, calculate the width that document shows object, when the overlap-add operation pagewidth of width, the demonstration object with the back is placed into next line.
Step S5, show the DICOM medical image in the audit report of audit report editing machine.
When the audit report editing machine showed audit report, at first traversal showed all pages of audit report in the audit report editing machine: when showing every one page, traversal shows all row in page; When showing every delegation, in the traversal display line, each document shows object.
Demonstration for the DICOM medical image, the filename of the DICOM medical image that at first comprises in the document storage object ImageNode according to medical image, we can get this DICOM medical image complete data in audit report editing machine buffer memory from imagePool by this document name, with these data encapsulation in the image object.
Then the image object is through exchanging the view data (principle that is namely the DIB bitmap by above-mentioned DICOM image transitions that window was processed, the DICOM image transitions is become the DIB bitmap), deposit in the data field of DIB bitmap object, so just set up the DIB bitmap of a storage DICOM image in audit report editing machine buffer memory.
Call windows api function StretchDIBits() pixel data in rectangular area in the DIB bitmap is copied to the target rectangle of appointment in audit report.Wherein, if target rectangle is big or small larger than source rectangle (rectangular area in the DIB bitmap), function can stretch to the row and column of color data so, to mate with target rectangle; If the target rectangle size is less than source rectangle, this function can compress ranks by the raster manipulation that uses appointment so.
Step S6, the medical image of DIB bitmap format is carried out the adjustment of window width and window level in the audit report of audit report editing machine.
At first the user clicks medical image in the audit report editing machine, the all documents of audit report editing machine traversal current page show object, if the document of medical image shows the viewing area of object and has comprised mouse position, the document of this medical image shows object response mouse click event, calls the onClick function.In the onClick function, current state that document shows object is set is selected state, and again be plotted to the interface.
When right button pulls on medical image as the user, the all documents of audit report editing machine traversal current page show object, if the document of medical image shows the viewing area of object and has comprised mouse position, the document of this medical image shows that object response right button pulls event, calls the onRightDrag function.In the onRightDrag function, the window width and window level value of image object is adjusted, then the image object regenerates the DIB bitmap according to the window width and window level value, again shows.
As shown in Figure 4, when pinning right button on two width medical images as the user in audit report and pulling, can realize the accent window operation of image (is pulled by the left and right, realizes the adjustment of window width size; By pulling up and down, realize the adjustment just of window position), and obtain in real time different image display effects.Pinning right button pulls and completes later display effect and change as shown in Figure 5.
The above is only preferred embodiment of the present invention, not in order to limiting the present invention, all any modifications of doing within the spirit and principles in the present invention, is equal to and replaces and improvement etc., within all should being included in protection scope of the present invention.