comparison UnitTestsSources/FromDcmtkTests.cpp @ 2861:9b4251721f22

ImageAccessor now non-copyable
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Oct 2018 17:46:02 +0200
parents 6db878376018
children 8b331be57606
comparison
equal deleted inserted replaced
2857:482631e4e290 2861:9b4251721f22
189 ImageBuffer img; 189 ImageBuffer img;
190 img.SetWidth(256); 190 img.SetWidth(256);
191 img.SetHeight(256); 191 img.SetHeight(256);
192 img.SetFormat(PixelFormat_Grayscale16); 192 img.SetFormat(PixelFormat_Grayscale16);
193 193
194 ImageAccessor accessor;
195 img.GetWriteableAccessor(accessor);
196
194 uint16_t v = 0; 197 uint16_t v = 0;
195 for (unsigned int y = 0; y < img.GetHeight(); y++) 198 for (unsigned int y = 0; y < img.GetHeight(); y++)
196 { 199 {
197 uint16_t *p = reinterpret_cast<uint16_t*>(img.GetAccessor().GetRow(y)); 200 uint16_t *p = reinterpret_cast<uint16_t*>(accessor.GetRow(y));
198 for (unsigned int x = 0; x < img.GetWidth(); x++, p++, v++) 201 for (unsigned int x = 0; x < img.GetWidth(); x++, p++, v++)
199 { 202 {
200 *p = v; 203 *p = v;
201 } 204 }
202 } 205 }
203 206
204 o.EmbedImage(img.GetAccessor()); 207 o.EmbedImage(accessor);
205 o.SaveToFile("UnitTestsResults/png4.dcm"); 208 o.SaveToFile("UnitTestsResults/png4.dcm");
206 } 209 }
207 } 210 }
208 211
209 212
864 { 867 {
865 *p = y; 868 *p = y;
866 } 869 }
867 } 870 }
868 871
869 Orthanc::ImageAccessor r = image.GetRegion(32, 32, 64, 192); 872 Orthanc::ImageAccessor r;
870 Orthanc::ImageProcessing::Set(r, 0); 873
871 r = image.GetRegion(160, 32, 64, 192); 874 image.GetRegion(r, 32, 32, 64, 192);
875 Orthanc::ImageProcessing::Set(r, 0);
876
877 image.GetRegion(r, 160, 32, 64, 192);
872 Orthanc::ImageProcessing::Set(r, 255); 878 Orthanc::ImageProcessing::Set(r, 255);
873 879
874 { 880 {
875 ParsedDicomFile f(true); 881 ParsedDicomFile f(true);
876 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.7"); 882 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.7");
980 { 986 {
981 *p = htole16(v); // Orthanc uses Little-Endian transfer syntax to encode images 987 *p = htole16(v); // Orthanc uses Little-Endian transfer syntax to encode images
982 } 988 }
983 } 989 }
984 990
985 Orthanc::ImageAccessor r = image.GetRegion(32, 32, 64, 192); 991 Orthanc::ImageAccessor r;
986 Orthanc::ImageProcessing::Set(r, 0); 992
987 r = image.GetRegion(160, 32, 64, 192); 993 image.GetRegion(r, 32, 32, 64, 192);
994 Orthanc::ImageProcessing::Set(r, 0);
995
996 image.GetRegion(r, 160, 32, 64, 192);
988 Orthanc::ImageProcessing::Set(r, 65535); 997 Orthanc::ImageProcessing::Set(r, 65535);
989 998
990 { 999 {
991 ParsedDicomFile f(true); 1000 ParsedDicomFile f(true);
992 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.7"); 1001 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.7");
1034 { 1043 {
1035 *p = htole16(v); // Orthanc uses Little-Endian transfer syntax to encode images 1044 *p = htole16(v); // Orthanc uses Little-Endian transfer syntax to encode images
1036 } 1045 }
1037 } 1046 }
1038 1047
1039 Orthanc::ImageAccessor r = image.GetRegion(32, 32, 64, 192); 1048 Orthanc::ImageAccessor r;
1040 Orthanc::ImageProcessing::Set(r, -32768); 1049 image.GetRegion(r, 32, 32, 64, 192);
1041 r = image.GetRegion(160, 32, 64, 192); 1050 Orthanc::ImageProcessing::Set(r, -32768);
1051
1052 image.GetRegion(r, 160, 32, 64, 192);
1042 Orthanc::ImageProcessing::Set(r, 32767); 1053 Orthanc::ImageProcessing::Set(r, 32767);
1043 1054
1044 { 1055 {
1045 ParsedDicomFile f(true); 1056 ParsedDicomFile f(true);
1046 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.7"); 1057 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.7");