1

I am trying to calculate two plane equations from the data of two dicom images and get an intersection line from these two plane equations. The dicom tag ImagePositionPatient has three coordinates x,y,z and the tag ImageOrientationPatient has two vectors each with three components. How equation of plane can be calculated using these three coordinates and two vectors?

This is my code:

public void ShowLocalizerLine(View v)
{
    //Getting The Values
    InfoOfFirst();  //This gets the img position and orientation of src img
    InfoOfSecond(); //This gets the img position and orientation of dst img
    String[] src_position_array = new String[3];
    src_position_array = firstimg_position.split("\\\\");
    Src_Position_Xo = Float.parseFloat(src_position_array[0]);
    Src_Position_Yo = Float.parseFloat(src_position_array[1]);
    Src_Position_Zo = Float.parseFloat(src_position_array[2]);

    String[] src_orientation_array = new String[6];
    src_orientation_array = firstimg_orientation.split("\\\\");
    Src_Orientation_Vector1_A = Float.parseFloat(src_orientation_array[0]);
    Src_Orientation_Vector1_B = Float.parseFloat(src_orientation_array[1]);
    Src_Orientation_Vector1_C = Float.parseFloat(src_orientation_array[2]);
    Src_Orientation_Vector2_D = Float.parseFloat(src_orientation_array[3]);
    Src_Orientation_Vector2_E = Float.parseFloat(src_orientation_array[4]);
    Src_Orientation_Vector2_F = Float.parseFloat(src_orientation_array[5]);

    String[] dst_position_array = new String[3];
    dst_position_array = secimg_position.split("\\\\");
    Dst_Position_Xo = Float.parseFloat(dst_position_array[0]);
    Dst_Position_Yo = Float.parseFloat(dst_position_array[1]);
    Dst_Position_Zo = Float.parseFloat(dst_position_array[2]);

    String[] dst_orientation_array = new String[6];
    dst_orientation_array = secimg_orientation.split("\\\\");
    Dst_Orientation_Vector1_A = Float.parseFloat(dst_orientation_array[0]);
    Dst_Orientation_Vector1_B = Float.parseFloat(dst_orientation_array[1]);
    Dst_Orientation_Vector1_C = Float.parseFloat(dst_orientation_array[2]);
    Dst_Orientation_Vector2_D = Float.parseFloat(dst_orientation_array[3]);
    Dst_Orientation_Vector2_E = Float.parseFloat(dst_orientation_array[4]);
    Dst_Orientation_Vector2_F = Float.parseFloat(dst_orientation_array[5]);

    //Calculations
    float dst_nrm_dircos_x = Dst_Orientation_Vector1_B*Dst_Orientation_Vector2_F - Dst_Orientation_Vector1_C*Dst_Orientation_Vector2_E;
    float dst_nrm_dircos_y = Dst_Orientation_Vector1_C*Dst_Orientation_Vector2_D - Dst_Orientation_Vector1_A*Dst_Orientation_Vector2_F;
    float dst_nrm_dircos_z = Dst_Orientation_Vector1_A*Dst_Orientation_Vector2_E - Dst_Orientation_Vector1_B*Dst_Orientation_Vector2_D;

    float src_pos_x = Src_Position_Xo - Dst_Position_Xo;
    float src_pos_y = Src_Position_Yo - Dst_Position_Yo;
    float src_pos_z = Src_Position_Zo - Dst_Position_Zo;
    float dst_pos_x = Dst_Orientation_Vector1_A*src_pos_x + Dst_Orientation_Vector1_B*src_pos_y + Dst_Orientation_Vector1_C*src_pos_z;
    float dst_pos_y = Dst_Orientation_Vector2_D*src_pos_x + Dst_Orientation_Vector2_E*src_pos_y + Dst_Orientation_Vector2_F*src_pos_z;
    float dst_pos_z = dst_nrm_dircos_x*src_pos_x + dst_nrm_dircos_y*src_pos_y + dst_nrm_dircos_z*src_pos_z;     
}
YakovL
  • 7,557
  • 12
  • 62
  • 102
NS.
  • 98
  • 1
  • 13
  • Is this really a programming question or is it more suited to Math.SE? – paisanco May 28 '16 at 15:59
  • @paisanco it is related to maths but the task need to be done in android app (java) – NS. May 28 '16 at 16:12
  • you only need two vectors to calculate the plane equation - its normal and a position; what are the 5 vectors you've presented? do they have variable names that hint at their purpose? –  May 28 '16 at 16:24
  • @paisanco i need some help with maths – NS. May 28 '16 at 16:27
  • @willywonka_dailyblah i dont have 5 vectors i have only two vectors both have three components – NS. May 28 '16 at 16:29
  • 1
    @paisanco i have edited my question and added the code here firstimg_position have three points and secimg_position have three points and firstimg_orientation have two vectors and secimg_orientation have two vectors and each vector contains three components need to calculate two plane equations: one for first image using its position (3 points) and orientation (two vectors) and other plane equation for second image using its position (three points) and its orientation (two vectors) so that at the end an intesection line can be calculated using these two plane equations – NS. May 28 '16 at 16:41

1 Answers1

1

From the class names I guess ImagePositionPatient gives a point (say a) on the plane and ImageOrientationPatient (say n) gives the normal. (I wouldn't know this is correct but since you told me they are 3D vectors this is what I have in mind).

Then your plane equation is given by dot(n, a) = dot(n, x), where x is the position variable and n is normalized. This gives Ax + By + Cz = D which is the Cartesian equation.