comparison OrthancStone/Sources/Toolbox/CoordinateSystem3D.cpp @ 1717:391c798e4dae

fix for KNIX sample dataset
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 01 Dec 2020 10:08:26 +0100
parents af312e145980
children 9ac2a65d4172
comparison
equal deleted inserted replaced
1716:6aadc7cbb8ea 1717:391c798e4dae
31 31
32 namespace OrthancStone 32 namespace OrthancStone
33 { 33 {
34 void CoordinateSystem3D::CheckAndComputeNormal() 34 void CoordinateSystem3D::CheckAndComputeNormal()
35 { 35 {
36 // DICOM expects normal vectors to define the axes: "The row and 36 /**
37 // column direction cosine vectors shall be normal, i.e., the dot 37 * DICOM expects normal vectors to define the axes: "The row and
38 // product of each direction cosine vector with itself shall be 38 * column direction cosine vectors shall be normal, i.e., the dot
39 // unity." 39 * product of each direction cosine vector with itself shall be
40 // http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.2.html 40 * unity."
41 * http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.2.html
42 **/
41 if (!LinearAlgebra::IsNear(boost::numeric::ublas::norm_2(axisX_), 1.0) || 43 if (!LinearAlgebra::IsNear(boost::numeric::ublas::norm_2(axisX_), 1.0) ||
42 !LinearAlgebra::IsNear(boost::numeric::ublas::norm_2(axisY_), 1.0)) 44 !LinearAlgebra::IsNear(boost::numeric::ublas::norm_2(axisY_), 1.0))
43 { 45 {
44 LOG(WARNING) << "Invalid 3D geometry: Axes are not normal vectors"; 46 LOG(WARNING) << "Invalid 3D geometry: Axes are not normal vectors";
45 SetupCanonical(); 47 SetupCanonical();
46 } 48 }
47 49
48 // The vectors within "Image Orientation Patient" must be 50 /**
49 // orthogonal, according to the DICOM specification: "The row and 51 * The vectors within "Image Orientation Patient" must be
50 // column direction cosine vectors shall be orthogonal, i.e., 52 * orthogonal, according to the DICOM specification: "The row and
51 // their dot product shall be zero." 53 * column direction cosine vectors shall be orthogonal, i.e.,
52 // http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.2.html 54 * their dot product shall be zero."
53 else if (!LinearAlgebra::IsCloseToZero(boost::numeric::ublas::inner_prod(axisX_, axisY_))) 55 * http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.2.html
56 *
57 * The "0.00001" threshold is needed for KNIX (on this sample
58 * image, the inner product equals "0.000003", which is rejected
59 * by "LinearAlgebra::IsCloseToZero()").
60 **/
61 else if (!LinearAlgebra::IsNear(0, boost::numeric::ublas::inner_prod(axisX_, axisY_), 0.00001))
54 { 62 {
55 LOG(WARNING) << "Invalid 3D geometry: Image orientation patient is not orthogonal"; 63 LOG(WARNING) << "Invalid 3D geometry: Image orientation patient is not orthogonal";
56 SetupCanonical(); 64 SetupCanonical();
57 } 65 }
58 else 66 else