/usr/include/dcmtk/dcmimgle/dimoimg.h is in libdcmtk-dev 3.6.2-3build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | /*
*
* Copyright (C) 1996-2016, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: dcmimgle
*
* Author: Joerg Riesmeier
*
* Purpose: DicomMonochromeImage (Header)
*
*/
#ifndef DIMOIMG_H
#define DIMOIMG_H
#include "dcmtk/config/osconfig.h"
#include "dcmtk/ofstd/ofcast.h"
#include "dcmtk/dcmimgle/diimage.h"
#include "dcmtk/dcmimgle/dimopx.h"
#include "dcmtk/dcmimgle/dimoopx.h"
#include "dcmtk/dcmimgle/didispfn.h"
/*------------------------*
* forward declarations *
*------------------------*/
class DiColorImage;
/*---------------------*
* class declaration *
*---------------------*/
/** Base class for monochrome images
*/
class DCMTK_DCMIMGLE_EXPORT DiMonoImage
: public DiImage
{
public:
/** constructor
*
** @param docu pointer to the DICOM document
* @param status status of the image object
*/
DiMonoImage(const DiDocument *docu,
const EI_Status status);
/** constructor, rescale
*
** @param docu pointer to the DICOM document
* @param status status of the image object
* @param slope rescale slope
* @param intercept rescale intercept
*/
DiMonoImage(const DiDocument *docu,
const EI_Status status,
const double slope,
const double intercept);
/** constructor, modality LUT
*
** @param docu pointer to the DICOM document
* @param status status of the image object
* @param data element containing the modality LUT data
* @param descriptor element containing the modality LUT descriptor
* @param explanation element containing the modality LUT explanation (optional)
*/
DiMonoImage(const DiDocument *docu,
const EI_Status status,
const DcmUnsignedShort &data,
const DcmUnsignedShort &descriptor,
const DcmLongString *explanation);
/** destructor
*/
virtual ~DiMonoImage();
/** process next couple of frames
*
** @param fcount number of frames to be processed (0 = same number as before)
*
** @return status, true if successful, false otherwise
*/
virtual int processNextFrames(const unsigned long fcount);
/** get minimum and maximum pixel values.
* the resulting pixel values are stored in 'double' variables to avoid problems
* with different number ranges, limited to monochrome images
*
** @param min minimum pixel value (reference parameter)
* @param max maximum pixel value (reference parameter)
* @param mode 0 = min/max 'used' pixel values,
* 1 = min/max 'possible' pixel values (absolute min/max)
*
** @return status code (true if successful)
*/
int getMinMaxValues(double &min,
double &max,
const int mode) const;
/** get display function
*
** @return pointer to current display function, NULL if absent
*/
DiDisplayFunction *getDisplayFunction() const
{
return DisplayFunction;
}
/** set display function
*
** @param display object describing the output device characteristic (only referenced!)
*
** @return true if successful, false otherwise
*/
int setDisplayFunction(DiDisplayFunction *display);
/** set no display function.
* disables display function transformation, object is not deleted!
*
** @return true if successful (1 = disabled current function,
* 2 = there was no function to disable)
* false otherwise
*/
int setNoDisplayFunction();
/** unset all VOI transformations (windows and LUTs).
* only applicable for monochrome images
*
** @return true if successful (1 = previous window/LUT has been valid,
* 2 = otherwise),
* false otherwise (image is invalid or not monochrome)
*/
int setNoVoiTransformation();
/** delete specified display LUT(s)
*
** @param bits parameter of LUT to be deleted (0 = all)
*
** @return true if successful, false otherwise
*/
inline int deleteDisplayLUT(const int bits)
{
return (DisplayFunction != NULL) ? DisplayFunction->deleteLookupTable(bits) : 0;
}
/** check whether given output value is unused
*
** @param value output value to be checked
*
** @return status, true if unused (1 = within output range, 2 = out of range), false otherwise
*/
inline int isValueUnused(const unsigned long value)
{
return (OutputData != NULL) ? OutputData->isUnused(value) : 0;
}
/** convert P-value to DDL.
* conversion uses display LUT if present, linear scaling otherwise.
*
** @param pvalue P-value to be converted (0..65535)
* @param ddl reference to resulting DDL
* @param bits number of bits for output
*
** @return true if successful (1 = display function transformation,
* 2 = linear scaling),
* false otherwise
*/
int convertPValueToDDL(const Uint16 pvalue,
Uint16 &ddl,
const int bits);
/** set automatically calculated minimum/maximum window.
* possibly active VOI LUT is implicitly disabled.
*
** @param idx ignore global min/max values if false (0)
*
** @return true if successful (1 = window has changed,
* 2 = new window is the same as previous one),
* false otherwise
*/
int setMinMaxWindow(const int idx = 1);
/** set automatically calculated VOI window for the specified Region of Interest (ROI).
* The ROI is specified by means of a rectangle (left_pos, top_pos, width, height).
* Possibly active VOI LUT is implicitly disabled.
*
** @param left_pos x-coordinate of the top left-hand corner of the ROI (starting from 0)
* @param top_pos y-coordinate of the top left-hand corner of the ROI (starting from 0)
* @param width width in pixels of the rectangular ROI (minimum: 1)
* @param height height in pixels of the rectangular ROI (minimum: 1)
* @param frame index of the frame to be used for the calculation
*
** @return true if successful (1 = window has changed,
* 2 = new window is the same as previous one),
* false otherwise
*/
int setRoiWindow(const unsigned long left_pos,
const unsigned long top_pos,
const unsigned long width,
const unsigned long height,
const unsigned long frame);
/** set automatically calculated histogram window.
* possibly active VOI LUT is implicitly disabled.
*
** @param thresh threshold value specifying percentage of histogram border which shall be ignored
*
** @return true if successful, false otherwise
*/
int setHistogramWindow(const double thresh);
/** set specified window (given by index to window width/center sequence stored in image file).
* possibly active VOI LUT is implicitly disabled.
*
** @param pos index to window width/center sequence
*
** @return true if successful, false otherwise
*/
int setWindow(const unsigned long pos = 0);
/** set specified window (given by window width and center).
* possibly active VOI LUT is implicitly disabled.
*
** @param center center of specified window
* @param width width of specified window
* @param explanation window explanation (optional)
*
** @return true if successful (1 = window has changed,
* 2 = new window is the same as previous one),
* false otherwise
*/
int setWindow(const double center,
const double width,
const char *explanation = NULL);
/** get current window center and width values
*
** @param center return current window center value
* @param width return current window width value
*
** @return true if successful, false otherwise
*/
int getWindow(double ¢er,
double &width);
/** get number of VOI windows (stored in image file)
*
** @return number of VOI windows
*/
inline unsigned long getWindowCount() const
{
return WindowCount;
}
/** get VOI LUT function.
* possible values are: EFV_Default, EFV_Linear, EFV_Sigmoid.
*
** @return currently active VOI LUT function
*/
EF_VoiLutFunction getVoiLutFunction() const;
/** set VOI LUT function
*
** @param function type of VOI LUT function (default, linear or sigmoid).
* 'default' basically means the same as 'linear'.
*
** @return true if successful (1 = function has changed,
* 2 = function has not changed)
* false otherwise
*/
int setVoiLutFunction(const EF_VoiLutFunction function);
/** set VOI LUT (given by dcmdata elements).
* possibly active window/center is implicitly disabled.
*
** @param data contains LUT data
* @param descriptor describes LUT structure
* @param explanation free form description of VOI LUT (optional)
* @param descripMode mode specifying the use of the bits per table entry value
*
** @return true if successful, false otherwise
*/
int setVoiLut(const DcmUnsignedShort &data,
const DcmUnsignedShort &descriptor,
const DcmLongString *explanation,
const EL_BitsPerTableEntry descripMode = ELM_UseValue);
/** set VOI LUT (given by index to VOI LUT sequence stored in image file).
* possibly active window/center is implicitly disabled.
*
** @param pos index to VOI LUT sequence
* @param descripMode mode specifying the use of the bits per table entry value
*
** @return true if successful, false otherwise
*/
int setVoiLut(const unsigned long pos,
const EL_BitsPerTableEntry descripMode = ELM_UseValue);
/** get number of VOI LUTs (stored in image file)
*
** @return number of VOI LUTs
*/
inline unsigned long getVoiLutCount() const
{
return VoiLutCount;
}
/** get description of active VOI transformation
*
** @return pointer to description text (NULL if absent)
*/
inline const char *getVoiTransformationExplanation() const
{
return VoiExplanation.c_str();
}
/** get description of specified VOI window (stored in the image file)
*
** @param pos index of the stored VOI window (0..n-1)
* @param explanation variable in which the result text is stored
*
** @return pointer to description text (NULL if absent or index invalid)
*/
const char *getVoiWindowExplanation(const unsigned long pos,
OFString &explanation) const;
/** get description of specified VOI LUT (stored in the image file)
*
** @param pos index of the stored VOI LUT (0..n-1)
* @param explanation variable in which the result text is stored
*
** @return pointer to description text (NULL if absent or index invalid)
*/
const char *getVoiLutExplanation(const unsigned long pos,
OFString &explanation) const;
/** get description of performed modality LUT transformation
*
** @return pointer to description text (NULL if absent)
*/
inline const char *getModalityLutExplanation() const
{
return (InterData != NULL) ? InterData->getModalityLutExplanation() : OFstatic_cast(const char *, NULL);
}
/** set hardcopy parameters. (used to display LinOD images)
*
** @param min minimum density of the print-out (in hundreds of Optical Density, e.g. 150 means 1.5 OD)
* @param max maximum density of the print-out (ditto)
* @param reflect reflected ambient light (in candela per square meter - cd/m^2)
* @param illumin illumination (ditto)
*
** @return true if successful (1 = at least one of the parameters has changed,
* 2 = no parameter has changed)
* false otherwise
*/
int setHardcopyParameters(const unsigned int min,
const unsigned int max,
const unsigned int reflect,
const unsigned int illumin);
/** get shape for presentation transformation.
* possible values are: ESP_Default, ESP_Identity, ESP_Inverse, ESP_LinOD
* If a presentation LUT is currently active ESP_Default is always returned.
*
** @return currently active presentation LUT shape
*/
ES_PresentationLut getPresentationLutShape() const;
/** set shape for presentation transformation.
* possibly active presentation LUT is implicitly disabled.
*
** @param shape presentation LUT shape (default, identity or inverse).
* 'default' means that the output data is always created with 0 for black
* and maxvalue for white (i.e. monochrome2 data is created for output).
*
** @return true if successful (1 = shape has changed,
* 2 = shape has not changed)
* false otherwise
*/
int setPresentationLutShape(const ES_PresentationLut shape);
/** set LUT for presentation transformation.
* possibly active presentation LUT is implicitly disabled.
*
** @param data contains LUT data
* @param descriptor describes LUT structure
* @param explanation free form description of presentation LUT (optional)
* @param descripMode mode specifying the use of the bits per table entry value
*
** @return true if successful, false otherwise
*/
int setPresentationLut(const DcmUnsignedShort &data,
const DcmUnsignedShort &descriptor,
const DcmLongString *explanation = NULL,
const EL_BitsPerTableEntry descripMode = ELM_UseValue);
/** set inverse LUT for presentation transformation.
* this LUT transform is e.g. used for DICOM print (12->8, 8->12 bit)
* possibly active presentation LUT will not be considered !
*
** @param data contains LUT data
* @param descriptor describes LUT structure
* @param descripMode mode specifying the use of the bits per table entry value
*
** @return true if successful, false otherwise
*/
int setInversePresentationLut(const DcmUnsignedShort &data,
const DcmUnsignedShort &descriptor,
const EL_BitsPerTableEntry descripMode = ELM_UseValue);
/** get description of active presentation LUT
*
** @return pointer to description text (NULL if absent)
*/
inline const char *getPresentationLutExplanation() const
{
return (PresLutData != NULL) ? PresLutData->getExplanation() : OFstatic_cast(const char *, NULL);
}
/** add specified plane to group of additional overlay planes.
* replaces old overlay plane if group number already exists.
*
** @param group group number (0x60nn) of overlay plane
* @param left_pos x coordinate of plane orgin (referring to image origin)
* @param top_pos y coordinate of plane origin
* @param columns width of overlay plane (in pixels)
* @param rows height of overlay plane (in pixels)
* @param data overlay plane data (dcmdata element)
* @param label overlay plane label
* @param description overlay plane description
* @param mode display mode (see 'diutils.h')
*
** @return false (0) if an error occurred, true otherwise (1 = added new plane,
* 2 = replaced existing plane)
*/
int addOverlay(const unsigned int group,
const signed int left_pos,
const signed int top_pos,
const unsigned int columns,
const unsigned int rows,
const DcmOverlayData &data,
const DcmLongString &label,
const DcmLongString &description,
const EM_Overlay mode);
/** remove all additional overlay planes
*
** @return false (0) if an error occurred, true otherwise
*/
int removeAllOverlays();
/** get pointer to specified overlay managing object
*
** @param idx index of overlay group (0 = dataset, 1 = additional)
*
** @return pointer to overlay managing object (NULL if absent or invalid)
*/
inline DiOverlay *getOverlayPtr(const unsigned int idx)
{
return (idx < 2) ? Overlays[idx] : OFstatic_cast(DiOverlay *, NULL);
}
/** get pointer to current monochrome image (this)
*
** @return pointer to this object
*/
inline DiMonoImage *getMonoImagePtr()
{
return this;
}
/** flip current image (horizontally and/or vertically)
*
** @param horz flip horizontally if true
* @param vert flip vertically if true
*
** @return true if successful (1 = flipped at least direction,
* 2 = not flipped, because of image resolution - width and/or height equal to 1),
* false otherwise
*/
int flip(const int horz,
const int vert);
/** rotate current image (by steps of 90 degrees)
*
** @param degree angle by which the image shall be rotated (-360, -270, -180, -90, 0, 90, 180, 270, 360)
*
** @return true if successful (1 = rotated by at least 90 degrees,
* 2 = not rotated, because of image resolution or angle),
* false otherwise
*/
int rotate(const int degree);
/** get number of bits per sample.
* If the optional parameter is specified the value will be checked and in any case
* a valid value will be returned.
*
** @param bits value to be returned (if less than 1 or greater than the maximum (32)
* the default value will be used which is equal to the bits per sample
* value stored in the DICOM dataset)
*
** @return status, true if successful, false otherwise
*/
virtual int getBits(const int bits = 0) const
{
return (((bits < 1) || (bits > MAX_BITS)) && (bits != MI_PastelColor)) ? BitsPerSample : bits;
}
/** get number of bytes required for the rendered output of a single frame
*
* @param bits number of bits for the output pixel data (depth)
*
** @return number of bytes if successful, 0 otherwise
*/
virtual unsigned long getOutputDataSize(const int bits = 0) const;
/** get pixel data with specified format.
* (memory is handled internally)
*
** @param frame number of frame to be rendered
* @param bits number of bits for the output pixel data (depth)
* @param planar flag, only useful for multi-planar images (color)
*
** @return untyped pointer to the pixel data if successful, NULL otherwise
*/
virtual const void *getOutputData(const unsigned long frame,
const int bits,
const int planar = 0) = 0;
/** get pixel data with specified format.
* (memory is handled externally)
*
** @param buffer untyped pointer to the externally allocated memory buffer
* @param size size of the memory buffer in bytes (will be checked)
* @param frame number of frame to be rendered
* @param bits number of bits for the output pixel data (depth)
* @param planar flag, only useful for multi-planar images (color)
*
** @return status, true if successful, false otherwise
*/
virtual int getOutputData(void *buffer,
const unsigned long size,
const unsigned long frame,
const int bits,
const int planar = 0) = 0;
/** get pixel data of specified plane.
* (memory is handled internally)
*
** @param dummy (not used)
*
** @return untyped pointer to the pixel data if successful, NULL otherwise
*/
const void *getOutputPlane(const int dummy) const;
/** delete internally handled output memory buffer
* Save memory if data is no longer needed.
*/
void deleteOutputData();
/** create bitmap for specified overlay plane.
* (up to 16 bits per pixel with two values: fore and back)
*
** @param frame index of frame used for output
* @param plane number (0..15) or group number (0x60nn) of overlay plane
* @param left_pos returns x coordinate of plane's origin
* @param top_pos returns y coordinate of plane's origin
* @param width returns width of overlay plane (in pixels)
* @param height returns height of overlay plane (in pixels)
* @param mode return display mode (see 'diutils.h')
* @param idx index of overlay group (0 = dataset, 1 = additional, 2 = '1' plane hides '0' plane)
* @param bits number of bits (stored) in the resulting array, default: 8
* @param fore foreground color to be set in bitmap, default: 255
* @param back background color to be set in bitmap (transparent), default: 0
*
** @return pointer to overlay plane data (internal memory buffer)
*/
const void *getOverlayData(const unsigned long frame,
const unsigned int plane,
unsigned int &left_pos,
unsigned int &top_pos,
unsigned int &width,
unsigned int &height,
EM_Overlay &mode,
const unsigned int idx,
const int bits = 8,
const Uint16 fore = 0xff,
const Uint16 back = 0x0);
/** create bitmap for specified overlay plane.
* (up to 16 bits per pixel with two values: fore and back)
*
** @param frame index of frame used for output
* @param plane number (0..15) or group number (0x60nn) of overlay plane
* @param width returns width of overlay plane (in pixels)
* @param height returns height of overlay plane (in pixels)
* @param idx index of overlay group (0 = dataset, 1 = additional, 2 = '1' plane hides '0' plane)
* @param bits number of bits (stored) in the resulting array, default: 8
* @param fore foreground color to be set in bitmap, default: 255
* @param back background color to be set in bitmap (transparent), default: 0
*
** @return pointer to overlay plane data (internal memory buffer)
*/
const void *getFullOverlayData(const unsigned long frame,
const unsigned int plane,
unsigned int &width,
unsigned int &height,
const unsigned int idx,
const int bits = 8,
const Uint16 fore = 0xff,
const Uint16 back = 0x0);
/** delete buffer for overlay plane data.
* Save memory if data is no longer needed.
*/
void deleteOverlayData();
/** create bitmap for specified overlay plane and store it in (6xxx,3000) format.
* (1 bit allocated and stored, foreground color is 1, background color is 0,
* data is 16 bit padded - even length)
* memory is not handled internally - must be deleted from calling program.
*
** @param buffer stores pointer to overlay data (memory is allocated internally)
* @param plane number (0..15) or group number (0x60nn) of overlay plane
* @param width returns width of overlay plane (in pixels)
* @param height returns height of overlay plane (in pixels)
* @param frames returns number of frames (multiple overlay frames possible!)
* @param idx index of overlay group (0 = dataset, planes stored in the image dataset;
* 1 = additional, planes added by addOverlay()),
* default: 0
*
** @return number of bytes allocated for the 'buffer' if successful, 0 otherwise
*/
unsigned long create6xxx3000OverlayData(Uint8 *&buffer,
const unsigned int plane,
unsigned int &width,
unsigned int &height,
unsigned long &frames,
const unsigned int idx = 0);
/** get pointer to intermediate pixel data representation
*
** @return pointer to intermediate pixel data
*/
const DiPixel *getInterData() const
{
return InterData;
}
/** get pointer to intermediate pixel data representation
*
** @return pointer to intermediate pixel data
*/
const DiMonoPixel *getMonoInterData() const
{
return InterData;
}
/** create true color (24/32 bit) or palette (8 bit) bitmap for MS Windows.
* memory is not handled internally - must be deleted from calling program.
*
** @param data untyped pointer memory buffer (set to NULL if not allocated externally)
* @param size size of the memory buffer in bytes (if 0 'data' is set to NULL)
* @param frame index of frame to be converted (starting from 0)
* @param bits number of bits per pixel used for the output bitmap (8, 24 or 32)
* @param upsideDown specifies the order of lines in the images (0 = top-down, bottom-up otherwise)
* @param padding align each line to a 32-bit address if true (default)
*
** @return number of bytes allocated by the bitmap, or 0 if an error occurred
*/
unsigned long createDIB(void *&data,
const unsigned long size,
const unsigned long frame,
const int bits,
const int upsideDown,
const int padding = 1);
/** create true color (32 bit) or palette (8 bit) bitmap for Java (AWT default format).
* Memory is not handled internally - must be deleted from calling program.
*
** @param data resulting pointer to bitmap data (set to NULL if an error occurred)
* @param frame index of frame to be converted (starting from 0)
* @param bits number of bits per pixel used for the output bitmap (8 or 32)
*
** @return number of bytes allocated by the bitmap, or 0 if an error occurred
*/
unsigned long createAWTBitmap(void *&data,
const unsigned long frame,
const int bits);
/** create packed bitmap (e.g. 12/16 bit -> 12/12 bit for DICOM printers).
* Memory is not handled internally - must be deleted from calling program.
*
** @param buffer pointer to input memory buffer
* @param size size of memory buffer (will be checked whether it is sufficient)
* @param count number of entries (pixels) in input buffer
* @param alloc number of bits allocated for the pixels stored in the buffer (e.g. 16)
* @param stored number of bits stored for the pixels stored in the buffer (e.g. 12)
*
** @return pointer to memory buffer containing the packed output bitmap data (NULL if an error occurred)
*/
static void *createPackedBitmap(const void *buffer,
const unsigned long size,
const unsigned long count,
const int alloc,
const int stored);
/** create new single frame DiImage with applied grayscale transformations.
* The method getOutputData() is used internally for the new bitmap.
*
** @param frame index of frame to be converted
* @param bits number of bits per pixel used for the output bitmap
*
** @return pointer to new DiImage object (NULL if an error occurred)
*/
DiImage *createOutputImage(const unsigned long frame,
const int bits);
/** write current image and related attributes to DICOM dataset.
*
** @param dataset reference to DICOM dataset where the image attributes are stored
* @param mode 0 = determine value of BitsStored from 'used' pixel values,
* 1 = determine value of BitsStored from 'possible' pixel values
* @param planar dummy parameter (only used for color images)
*
** @return true if successful, false otherwise
*/
int writeImageToDataset(DcmItem &dataset,
const int mode,
const int planar);
/** write pixel data to PPM file.
* pixel data is written in ASCII format.
*
** @param stream open C++ output stream
* @param frame index of frame used for output
* @param bits number of bits used for output of pixel data
*
** @return true if successful, false otherwise
*/
int writePPM(STD_NAMESPACE ostream& stream,
const unsigned long frame,
const int bits);
/** write pixel data to PPM file.
* pixel data is written in ASCII format.
*
** @param stream open C output stream
* @param frame index of frame used for output
* @param bits number of bits used for output of pixel data
*
** @return true if successful, false otherwise
*/
int writePPM(FILE *stream,
const unsigned long frame,
const int bits);
/** write pixel data to raw PPM file
*
** @param stream open C output stream
* @param frame index of frame used for output
* @param bits number of bits used for output of pixel data
*
** @return true if successful, false otherwise
*/
int writeRawPPM(FILE *stream,
const unsigned long frame,
const int bits);
/** write pixel data to BMP file
*
** @param stream open C output stream
* @param frame index of frame used for output (default: first frame = 0)
* @param bits number of bits used for output of pixel data (8, 24 or 32, default (0) = 8)
*
** @return true if successful, false otherwise
*/
int writeBMP(FILE *stream,
const unsigned long frame,
const int bits);
protected:
/** constructor
*
** @param image pointer to dataset (encapsulated)
* @param status current image status
* @param dummy (necessary to be different from another constructor)
*/
DiMonoImage(const DiDocument *image,
const EI_Status status,
const char dummy);
/** constructor, copy
*
** @param image pointer to reference image
* @param fstart first frame to be processed
* @param fcount number of frames
*/
DiMonoImage(const DiMonoImage *image,
const unsigned long fstart,
const unsigned long fcount);
/** constructor, convert color images to monochrome
*
** @param image pointer to reference image
* @param red coefficient by which the red component is weighted
* @param green coefficient by which the green component is weighted
* @param blue coefficient by which the blue component is weighted
*
** @return pointer to new DiImage object (NULL if an error occurred)
*/
DiMonoImage(const DiColorImage *image,
const double red,
const double green,
const double blue);
/** constructor, scale/clip
*
** @param image pointer to reference image
* @param left_pos x coordinate of top left corner of area to be scaled
* (referring to image origin, negative values create a border around the image)
* @param top_pos y coordinate of top left corner of area to be scaled
* @param src_cols width of area to be scaled
* @param src_rows height of area to be scaled
* @param dest_cols width of scaled image (in pixels)
* @param dest_rows height of scaled image (in pixels)
* @param interpolate specifies whether scaling algorithm should use interpolation (if necessary).
* default: no interpolation (0), preferred interpolation algorithm (if applicable):
* 1 = pbmplus algorithm, 2 = c't algorithm, 3 = bilinear magnification,
* 4 = bicubic magnification
* @param aspect specifies whether pixel aspect ratio should be taken into consideration
* (if true, width OR height should be 0, i.e. this component will be calculated
* automatically)
* @param pvalue P-value used for the border outside the image (0..65535)
*/
DiMonoImage(const DiMonoImage *image,
const signed long left_pos,
const signed long top_pos,
const Uint16 src_cols,
const Uint16 src_rows,
const Uint16 dest_cols,
const Uint16 dest_rows,
const int interpolate,
const int aspect,
const Uint16 pvalue);
/** constructor, flip
*
** @param image pointer to reference image
** @param horz flip horizontally if true
* @param vert flip vertically if true
*/
DiMonoImage(const DiMonoImage *image,
const int horz,
const int vert);
/** constructor, rotate
*
** @param image pointer to reference image
* @param degree angle by which the image shall be rotated
*/
DiMonoImage(const DiMonoImage *image,
const int degree);
/** constructor, createMonoOutput
*
** @param image pointer to reference image
* @param pixel pointer to output pixel data used for the new image
* @param frame number of frame stored in the new image object
* @param stored number of bits stored
* @param alloc number of bits allocated
*/
DiMonoImage(const DiMonoImage *image,
DiMonoOutputPixel *pixel,
const unsigned long frame,
const int stored,
const int alloc);
/** initialize internal data structures and member variables
*
** @param modality pointer to object handling the modality transform
* @param reuse reuse particular information determined in a previous call
*/
void Init(DiMonoModality *modality,
const OFBool reuse = OFFalse);
/** initialize internal data structures (for Uint8)
*
** @param modality pointer to object handling the modality transform
*/
void InitUint8(DiMonoModality *modality);
/** initialize internal data structures (for Sint8)
*
** @param modality pointer to object handling the modality transform
*/
void InitSint8(DiMonoModality *modality);
/** initialize internal data structures (for Uint16)
*
** @param modality pointer to object handling the modality transform
*/
void InitUint16(DiMonoModality *modality);
/** initialize internal data structures (for Sint16)
*
** @param modality pointer to object handling the modality transform
*/
void InitSint16(DiMonoModality *modality);
/** initialize internal data structures (for Uint32)
*
** @param modality pointer to object handling the modality transform
*/
void InitUint32(DiMonoModality *modality);
/** initialize internal data structures (for Sint32)
*
** @param modality pointer to object handling the modality transform
*/
void InitSint32(DiMonoModality *modality);
/** check intermediate pixel representation for consistency
*
** @param mode check number of pixels stored in the dataset if true
*
** @return status, true if successful, false otherwise
*/
int checkInterData(const int mode = 1);
/** update Image Pixel Module attributes in the given dataset.
* Removes possibly existing embedded overlay planes and replaces any
* present modality transformation by a linear rescale/slope.
* Used in writeXXXToDataset() routines.
*
** @param dataset reference to DICOM image dataset
*/
virtual void updateImagePixelModuleAttributes(DcmItem &dataset);
/** get pixel data with specified format.
* (memory is handled externally)
*
** @param buffer untyped pointer to the externally allocated memory buffer
* @param size size of the memory buffer in bytes (will be checked)
* @param frame number of frame to be rendered
* @param bits number of bits for the output pixel data (depth)
* @param planar flag, only useful for multi-planar images (color)
* @param negative invert pixel data if true
*
** @return untyped pointer to the pixel data if successful, NULL otherwise
*/
const void *getData(void *buffer,
const unsigned long size,
const unsigned long frame,
int bits,
const int planar,
const int negative);
/** get pixel data with specified format for Uint8 input (helper function).
* (memory is handled externally)
*
** @param buffer untyped pointer to the externally allocated memory buffer
* @param disp pointer to current display function object
* @param samples number of samples per pixel
* @param frame number of frame to be rendered
* @param bits number of bits for the output pixel data (depth)
* @param low output pixel value to which 0 is mapped (min)
* @param high output pixel value to which 2^bits-1 is mapped (max)
*/
void getDataUint8(void *buffer,
DiDisplayFunction *disp,
const int samples,
const unsigned long frame,
const int bits,
const Uint32 low,
const Uint32 high);
/** get pixel data with specified format for Sint8 input (helper function).
* (memory is handled externally)
*
** @param buffer untyped pointer to the externally allocated memory buffer
* @param disp pointer to current display function object
* @param samples number of samples per pixel
* @param frame number of frame to be rendered
* @param bits number of bits for the output pixel data (depth)
* @param low output pixel value to which 0 is mapped (min)
* @param high output pixel value to which 2^bits-1 is mapped (max)
*/
void getDataSint8(void *buffer,
DiDisplayFunction *disp,
const int samples,
const unsigned long frame,
const int bits,
const Uint32 low,
const Uint32 high);
/** get pixel data with specified format for Uint16 input (helper function).
* (memory is handled externally)
*
** @param buffer untyped pointer to the externally allocated memory buffer
* @param disp pointer to current display function object
* @param samples number of samples per pixel
* @param frame number of frame to be rendered
* @param bits number of bits for the output pixel data (depth)
* @param low output pixel value to which 0 is mapped (min)
* @param high output pixel value to which 2^bits-1 is mapped (max)
*/
void getDataUint16(void *buffer,
DiDisplayFunction *disp,
const int samples,
const unsigned long frame,
const int bits,
const Uint32 low,
const Uint32 high);
/** get pixel data with specified format for Sint16 input (helper function).
* (memory is handled externally)
*
** @param buffer untyped pointer to the externally allocated memory buffer
* @param disp pointer to current display function object
* @param samples number of samples per pixel
* @param frame number of frame to be rendered
* @param bits number of bits for the output pixel data (depth)
* @param low output pixel value to which 0 is mapped (min)
* @param high output pixel value to which 2^bits-1 is mapped (max)
*/
void getDataSint16(void *buffer,
DiDisplayFunction *disp,
const int samples,
const unsigned long frame,
const int bits,
const Uint32 low,
const Uint32 high);
/** get pixel data with specified format for Uint32 input (helper function).
* (memory is handled externally)
*
** @param buffer untyped pointer to the externally allocated memory buffer
* @param disp pointer to current display function object
* @param samples number of samples per pixel
* @param frame number of frame to be rendered
* @param bits number of bits for the output pixel data (depth)
* @param low output pixel value to which 0 is mapped (min)
* @param high output pixel value to which 2^bits-1 is mapped (max)
*/
void getDataUint32(void *buffer,
DiDisplayFunction *disp,
const int samples,
const unsigned long frame,
const int bits,
const Uint32 low,
const Uint32 high);
/** get pixel data with specified format for Sint32 input (helper function).
* (memory is handled externally)
*
** @param buffer untyped pointer to the externally allocated memory buffer
* @param disp pointer to current display function object
* @param samples number of samples per pixel
* @param frame number of frame to be rendered
* @param bits number of bits for the output pixel data (depth)
* @param low output pixel value to which 0 is mapped (min)
* @param high output pixel value to which 2^bits-1 is mapped (max)
*/
void getDataSint32(void *buffer,
DiDisplayFunction *disp,
const int samples,
const unsigned long frame,
const int bits,
const Uint32 low,
const Uint32 high);
/** create a presentation look-up table converting the pixel data which is linear to
* Optical Density to DDLs of the softcopy device (used to display print images on screen).
*
** @param count number of LUT entries
* @param bits number of bits per entry
*
** @return true if successful, false otherwise
*/
int createLinODPresentationLut(const unsigned long count, const int bits);
/// center of current VOI-window
double WindowCenter;
/// width of current VOI-window
double WindowWidth;
/// number of stored VOI-windows
unsigned long WindowCount;
/// number of stored VOU-LUTs
unsigned long VoiLutCount;
/// true, if current VOI-window is valid
int ValidWindow;
/// free text explanation of current VOI transformation
OFString VoiExplanation;
/// VOI LUT function (linear or sigmoid)
EF_VoiLutFunction VoiLutFunction;
/// presentation LUT shape (identity, inverse or lin od)
ES_PresentationLut PresLutShape;
/// minimum density of a print-out (in hundreds of Optical Density)
unsigned int MinDensity;
/// maximum density of a print-out (ditto)
unsigned int MaxDensity;
/// reflected ambient light (in candela per square meter)
unsigned int Reflection;
/// illumination (ditto)
unsigned int Illumination;
/// points to associated overlay-objects ([0] = built-in, [1] = additional)
DiOverlay *Overlays[2];
/// points to associated VOI-LUT-object
DiLookupTable *VoiLutData;
/// points to associated presentation-LUT-object
DiLookupTable *PresLutData;
/// points to intermediate pixel data representation (object)
DiMonoPixel *InterData;
/// points to grayscale standard display function (only referenced!)
DiDisplayFunction *DisplayFunction;
private:
/// points to current output data (object)
DiMonoOutputPixel *OutputData;
/// points to current overlay plane data (pixel array)
void *OverlayData;
// --- declarations to avoid compiler warnings
DiMonoImage(const DiMonoImage &);
DiMonoImage &operator=(const DiMonoImage &);
};
#endif
|