![]() |
![]() |
||||||||||||||||||||||
|
|
|
MEDx Frequently Asked Questions - Input/OutputQ: How is shared memory used from withing ImageScript to send data to external programs?The MEDx API includes two functions, MxExternCanvas and MxInternCanvas, to transfer image data out of MEDx and back into MEDx. Image Data can be transferred to an outside program ( such as a C program ) via shared memory segments. Image data is placed into the shared memory via MxExternCanvas which returns the shared memory ID for the segment. This ID is passed to the outside program which can then use it to get the address of (pointer to) the shared memory segment. Once the outside program has finished, the script can then either bring the modified image data back into MEDx via MxInternCanvas or simply release the shared memory segment. Additionally, a parameter in the call to MxInternCanvas can be set which will allow the image data to be brought back into MEDx without releasing the shared memory segment for further processing.
To access the data the program only needs to make a call to the shared memory routine, shmat, for each image or volume. The shared memory ID's are passed to the program simply as command line arguments. Thecalls to shmat return a pointer to the shared memory which one can then use as any other pointer to memory. The shared memory segment is one contiguous block of data. The data is organized in a row-column-slice order meaning that the data begins with the first row of the first slice. Thus, Voxel(x,y,z) is at an offset given by the following expression [(z*height + y)*width + x]. The final step is to detach from the shared memory segment using the shmdt function. After your program has detached from the segment and you have used the MxInternCanvas function in your Tcl script with the FreeTransport boolean set to true the memory is released. Since the shared memory segment can not be freed if any process is still attached to it, it is important to include the call to shmdt() at the end of your program for any segment your program attaches to. For more information, including an example see MxExternCanvas and MxInternCanvas.
Other FAQ Topics If you have a question that you would like to see addressed in our list of Frequently Asked Questions, please contact customer support. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
|