comparison UnitTestsSources/UnitTestsMain.cpp @ 93:5945e81734a3 wasm

decoding of JPEG images
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 May 2017 17:28:31 +0200
parents f244018a4e4b
children fcec0ab44054
comparison
equal deleted inserted replaced
92:961ee171d933 93:5945e81734a3
46 { 46 {
47 printf(">> %d\n", (int) loader.GetSliceCount()); 47 printf(">> %d\n", (int) loader.GetSliceCount());
48 48
49 for (size_t i = 0; i < loader.GetSliceCount(); i++) 49 for (size_t i = 0; i < loader.GetSliceCount(); i++)
50 { 50 {
51 const_cast<OrthancSlicesLoader&>(loader).ScheduleLoadSliceImage(i); 51 const_cast<OrthancSlicesLoader&>(loader).ScheduleLoadSliceImage(i, SliceImageQuality_Full);
52 } 52 }
53 } 53 }
54 54
55 virtual void NotifyGeometryError(const OrthancSlicesLoader& loader) 55 virtual void NotifyGeometryError(const OrthancSlicesLoader& loader)
56 { 56 {
58 } 58 }
59 59
60 virtual void NotifySliceImageReady(const OrthancSlicesLoader& loader, 60 virtual void NotifySliceImageReady(const OrthancSlicesLoader& loader,
61 unsigned int sliceIndex, 61 unsigned int sliceIndex,
62 const Slice& slice, 62 const Slice& slice,
63 Orthanc::ImageAccessor* image) 63 Orthanc::ImageAccessor* image,
64 SliceImageQuality quality)
64 { 65 {
65 std::auto_ptr<Orthanc::ImageAccessor> tmp(image); 66 std::auto_ptr<Orthanc::ImageAccessor> tmp(image);
66 printf("Slice OK %dx%d\n", tmp->GetWidth(), tmp->GetHeight()); 67 printf("Slice OK %dx%d\n", tmp->GetWidth(), tmp->GetHeight());
67 } 68 }
68 69
69 virtual void NotifySliceImageError(const OrthancSlicesLoader& loader, 70 virtual void NotifySliceImageError(const OrthancSlicesLoader& loader,
70 unsigned int sliceIndex, 71 unsigned int sliceIndex,
71 const Slice& slice) 72 const Slice& slice,
73 SliceImageQuality quality)
72 { 74 {
73 printf("ERROR 2\n"); 75 printf("ERROR 2\n");
74 } 76 }
75 }; 77 };
76 78
77 79
78 class OrthancVolumeImageLoader : 80 class OrthancVolumeImage :
79 public SlicedVolumeBase, 81 public SlicedVolumeBase,
80 private OrthancSlicesLoader::ICallback 82 private OrthancSlicesLoader::ICallback
81 { 83 {
82 private: 84 private:
83 OrthancSlicesLoader loader_; 85 OrthancSlicesLoader loader_;
90 assert(downloadStack_.get() != NULL); 92 assert(downloadStack_.get() != NULL);
91 93
92 unsigned int slice; 94 unsigned int slice;
93 if (downloadStack_->Pop(slice)) 95 if (downloadStack_->Pop(slice))
94 { 96 {
95 loader_.ScheduleLoadSliceImage(slice); 97 loader_.ScheduleLoadSliceImage(slice, SliceImageQuality_Full);
96 } 98 }
97 } 99 }
98 100
99 101
100 static bool IsCompatible(const Slice& a, 102 static bool IsCompatible(const Slice& a,
170 spacingZ = 1; 172 spacingZ = 1;
171 } 173 }
172 174
173 for (size_t i = 1; i < loader.GetSliceCount(); i++) 175 for (size_t i = 1; i < loader.GetSliceCount(); i++)
174 { 176 {
175 if (!GeometryToolbox::IsNear(spacingZ, GetDistance(loader.GetSlice(i - 1), loader.GetSlice(i)))) 177 printf("%d %s %f\n", i, loader.GetSlice(i).GetOrthancInstanceId().c_str(),
178 GetDistance(loader.GetSlice(i - 1), loader.GetSlice(i)));
179
180 if (!GeometryToolbox::IsNear(spacingZ, GetDistance(loader.GetSlice(i - 1), loader.GetSlice(i)),
181 0.001 /* this is expressed in mm */))
176 { 182 {
177 LOG(ERROR) << "The distance between successive slices is not constant in a volume image"; 183 LOG(ERROR) << "The distance between successive slices is not constant in a volume image";
178 SlicedVolumeBase::NotifyGeometryError(); 184 SlicedVolumeBase::NotifyGeometryError();
179 return; 185 return;
180 } 186 }
208 } 214 }
209 215
210 virtual void NotifySliceImageReady(const OrthancSlicesLoader& loader, 216 virtual void NotifySliceImageReady(const OrthancSlicesLoader& loader,
211 unsigned int sliceIndex, 217 unsigned int sliceIndex,
212 const Slice& slice, 218 const Slice& slice,
213 Orthanc::ImageAccessor* image) 219 Orthanc::ImageAccessor* image,
220 SliceImageQuality quality)
214 { 221 {
215 std::auto_ptr<Orthanc::ImageAccessor> protection(image); 222 std::auto_ptr<Orthanc::ImageAccessor> protection(image);
216 223
217 { 224 {
218 ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, sliceIndex); 225 ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, sliceIndex);
224 ScheduleSliceDownload(); 231 ScheduleSliceDownload();
225 } 232 }
226 233
227 virtual void NotifySliceImageError(const OrthancSlicesLoader& loader, 234 virtual void NotifySliceImageError(const OrthancSlicesLoader& loader,
228 unsigned int sliceIndex, 235 unsigned int sliceIndex,
229 const Slice& slice) 236 const Slice& slice,
237 SliceImageQuality quality)
230 { 238 {
231 LOG(ERROR) << "Cannot download slice " << sliceIndex << " in a volume image"; 239 LOG(ERROR) << "Cannot download slice " << sliceIndex << " in a volume image";
232 ScheduleSliceDownload(); 240 ScheduleSliceDownload();
233 } 241 }
234 242
235 public: 243 public:
236 OrthancVolumeImageLoader(IWebService& orthanc) : 244 OrthancVolumeImage(IWebService& orthanc) :
237 loader_(*this, orthanc) 245 loader_(*this, orthanc)
238 { 246 {
239 } 247 }
240 248
241 void ScheduleLoadSeries(const std::string& seriesId) 249 void ScheduleLoadSeries(const std::string& seriesId)
255 } 263 }
256 264
257 virtual const Slice& GetSlice(size_t index) const 265 virtual const Slice& GetSlice(size_t index) const
258 { 266 {
259 return loader_.GetSlice(index); 267 return loader_.GetSlice(index);
268 }
269
270 ImageBuffer3D& GetImage()
271 {
272 if (image_.get() == NULL)
273 {
274 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
275 }
276 else
277 {
278 return *image_;
279 }
260 } 280 }
261 }; 281 };
262 } 282 }
263 283
264 284
294 OrthancStone::Oracle oracle(4); 314 OrthancStone::Oracle oracle(4);
295 oracle.Start(); 315 oracle.Start();
296 316
297 Orthanc::WebServiceParameters web; 317 Orthanc::WebServiceParameters web;
298 OrthancStone::OracleWebService orthanc(oracle, web); 318 OrthancStone::OracleWebService orthanc(oracle, web);
299 OrthancStone::OrthancVolumeImageLoader volume(orthanc); 319 OrthancStone::OrthancVolumeImage volume(orthanc);
300 320
301 volume.ScheduleLoadInstance("19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5", 0); 321 //volume.ScheduleLoadInstance("19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5", 0);
302 //volume.ScheduleLoadSeries("318603c5-03e8cffc-a82b6ee1-3ccd3c1e-18d7e3bb"); // COMUNIX PET 322 //volume.ScheduleLoadSeries("318603c5-03e8cffc-a82b6ee1-3ccd3c1e-18d7e3bb"); // COMUNIX PET
323 //volume.ScheduleLoadSeries("7124dba7-09803f33-98b73826-33f14632-ea842d29"); // COMUNIX CT
303 //volume.ScheduleLoadSeries("5990e39c-51e5f201-fe87a54c-31a55943-e59ef80e"); // Delphine sagital 324 //volume.ScheduleLoadSeries("5990e39c-51e5f201-fe87a54c-31a55943-e59ef80e"); // Delphine sagital
325 volume.ScheduleLoadSeries("6f1b492a-e181e200-44e51840-ef8db55e-af529ab6"); // Delphine ax 2.5
304 326
305 boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); 327 boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
306 328
307 oracle.Stop(); 329 oracle.Stop();
308 } 330 }