comparison OrthancServer/ParsedDicomFile.cpp @ 1941:d7b176f7dd1b

test dicom patterns
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Mar 2016 11:27:38 +0100
parents e251606c1433
children 76ff6eecf07f
comparison
equal deleted inserted replaced
1940:5514d37176b4 1941:d7b176f7dd1b
931 931
932 void ParsedDicomFile::EmbedImage(const ImageAccessor& accessor) 932 void ParsedDicomFile::EmbedImage(const ImageAccessor& accessor)
933 { 933 {
934 if (accessor.GetFormat() != PixelFormat_Grayscale8 && 934 if (accessor.GetFormat() != PixelFormat_Grayscale8 &&
935 accessor.GetFormat() != PixelFormat_Grayscale16 && 935 accessor.GetFormat() != PixelFormat_Grayscale16 &&
936 accessor.GetFormat() != PixelFormat_SignedGrayscale16 &&
936 accessor.GetFormat() != PixelFormat_RGB24 && 937 accessor.GetFormat() != PixelFormat_RGB24 &&
937 accessor.GetFormat() != PixelFormat_RGBA32) 938 accessor.GetFormat() != PixelFormat_RGBA32)
938 { 939 {
939 throw OrthancException(ErrorCode_NotImplemented); 940 throw OrthancException(ErrorCode_NotImplemented);
940 } 941 }
949 Remove(DICOM_TAG_PIXEL_DATA); 950 Remove(DICOM_TAG_PIXEL_DATA);
950 Replace(DICOM_TAG_COLUMNS, boost::lexical_cast<std::string>(accessor.GetWidth())); 951 Replace(DICOM_TAG_COLUMNS, boost::lexical_cast<std::string>(accessor.GetWidth()));
951 Replace(DICOM_TAG_ROWS, boost::lexical_cast<std::string>(accessor.GetHeight())); 952 Replace(DICOM_TAG_ROWS, boost::lexical_cast<std::string>(accessor.GetHeight()));
952 Replace(DICOM_TAG_SAMPLES_PER_PIXEL, "1"); 953 Replace(DICOM_TAG_SAMPLES_PER_PIXEL, "1");
953 Replace(DICOM_TAG_NUMBER_OF_FRAMES, "1"); 954 Replace(DICOM_TAG_NUMBER_OF_FRAMES, "1");
954 Replace(DICOM_TAG_PIXEL_REPRESENTATION, "0"); // Unsigned pixels 955
956 if (accessor.GetFormat() == PixelFormat_SignedGrayscale16)
957 {
958 Replace(DICOM_TAG_PIXEL_REPRESENTATION, "1");
959 }
960 else
961 {
962 Replace(DICOM_TAG_PIXEL_REPRESENTATION, "0"); // Unsigned pixels
963 }
964
955 Replace(DICOM_TAG_PLANAR_CONFIGURATION, "0"); // Color channels are interleaved 965 Replace(DICOM_TAG_PLANAR_CONFIGURATION, "0"); // Color channels are interleaved
956 Replace(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2"); 966 Replace(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2");
957 Replace(DICOM_TAG_BITS_ALLOCATED, "8"); 967
958 Replace(DICOM_TAG_BITS_STORED, "8"); 968 unsigned int bytesPerPixel = 0;
959 Replace(DICOM_TAG_HIGH_BIT, "7");
960
961 unsigned int bytesPerPixel = 1;
962 969
963 switch (accessor.GetFormat()) 970 switch (accessor.GetFormat())
964 { 971 {
972 case PixelFormat_Grayscale8:
973 Replace(DICOM_TAG_BITS_ALLOCATED, "8");
974 Replace(DICOM_TAG_BITS_STORED, "8");
975 Replace(DICOM_TAG_HIGH_BIT, "7");
976 bytesPerPixel = 1;
977 break;
978
965 case PixelFormat_RGB24: 979 case PixelFormat_RGB24:
966 case PixelFormat_RGBA32: 980 case PixelFormat_RGBA32:
967 Replace(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "RGB"); 981 Replace(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "RGB");
968 Replace(DICOM_TAG_SAMPLES_PER_PIXEL, "3"); 982 Replace(DICOM_TAG_SAMPLES_PER_PIXEL, "3");
983 Replace(DICOM_TAG_BITS_ALLOCATED, "8");
984 Replace(DICOM_TAG_BITS_STORED, "8");
985 Replace(DICOM_TAG_HIGH_BIT, "7");
969 bytesPerPixel = 3; 986 bytesPerPixel = 3;
970 break; 987 break;
971 988
972 case PixelFormat_Grayscale8:
973 break;
974
975 case PixelFormat_Grayscale16: 989 case PixelFormat_Grayscale16:
990 case PixelFormat_SignedGrayscale16:
976 Replace(DICOM_TAG_BITS_ALLOCATED, "16"); 991 Replace(DICOM_TAG_BITS_ALLOCATED, "16");
977 Replace(DICOM_TAG_BITS_STORED, "16"); 992 Replace(DICOM_TAG_BITS_STORED, "16");
978 Replace(DICOM_TAG_HIGH_BIT, "15"); 993 Replace(DICOM_TAG_HIGH_BIT, "15");
979 bytesPerPixel = 2; 994 bytesPerPixel = 2;
980 break; 995 break;
981 996
982 default: 997 default:
983 throw OrthancException(ErrorCode_NotImplemented); 998 throw OrthancException(ErrorCode_NotImplemented);
984 } 999 }
1000
1001 assert(bytesPerPixel != 0);
985 1002
986 DcmTag key(DICOM_TAG_PIXEL_DATA.GetGroup(), 1003 DcmTag key(DICOM_TAG_PIXEL_DATA.GetGroup(),
987 DICOM_TAG_PIXEL_DATA.GetElement()); 1004 DICOM_TAG_PIXEL_DATA.GetElement());
988 1005
989 std::auto_ptr<DcmPixelData> pixels(new DcmPixelData(key)); 1006 std::auto_ptr<DcmPixelData> pixels(new DcmPixelData(key));