comparison Core/DicomFormat/DicomImageInformation.cpp @ 854:ff530685e46a jpeg

fast version of image copy
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 Jun 2014 12:35:08 +0200
parents 839be3022203
children 6d89d5a4a723
comparison
equal deleted inserted replaced
853:839be3022203 854:ff530685e46a
53 53
54 try 54 try
55 { 55 {
56 width_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_COLUMNS).AsString()); 56 width_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_COLUMNS).AsString());
57 height_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_ROWS).AsString()); 57 height_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_ROWS).AsString());
58 samplesPerPixel_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_SAMPLES_PER_PIXEL).AsString());
59 bitsAllocated_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_BITS_ALLOCATED).AsString()); 58 bitsAllocated_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_BITS_ALLOCATED).AsString());
59
60 try
61 {
62 samplesPerPixel_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_SAMPLES_PER_PIXEL).AsString());
63 }
64 catch (OrthancException&)
65 {
66 samplesPerPixel_ = 1; // Assume 1 color channel
67 }
60 68
61 try 69 try
62 { 70 {
63 bitsStored_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_BITS_STORED).AsString()); 71 bitsStored_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_BITS_STORED).AsString());
64 } 72 }
145 bytesPerPixel_ = bitsAllocated_ / 8; 153 bytesPerPixel_ = bitsAllocated_ / 8;
146 154
147 isPlanar_ = (planarConfiguration != 0 ? true : false); 155 isPlanar_ = (planarConfiguration != 0 ? true : false);
148 isSigned_ = (pixelRepresentation != 0 ? true : false); 156 isSigned_ = (pixelRepresentation != 0 ? true : false);
149 } 157 }
158
159
160 bool DicomImageInformation::ExtractPixelFormat(PixelFormat& format) const
161 {
162 if (IsPlanar())
163 {
164 return false;
165 }
166
167 if (GetBitsStored() == 8 && GetChannelCount() == 1 && !IsSigned())
168 {
169 format = PixelFormat_Grayscale8;
170 return true;
171 }
172
173 if (GetBitsStored() == 8 && GetChannelCount() == 3 && !IsSigned())
174 {
175 format = PixelFormat_RGB24;
176 return true;
177 }
178
179 if (GetBitsStored() >= 9 && GetBitsStored() <= 16 && GetChannelCount() == 1 && !IsSigned())
180 {
181 format = PixelFormat_Grayscale16;
182 return true;
183 }
184
185 if (GetBitsStored() >= 9 && GetBitsStored() <= 16 && GetChannelCount() == 1 && IsSigned())
186 {
187 format = PixelFormat_SignedGrayscale16;
188 return true;
189 }
190
191 return false;
192 }
150 } 193 }