Coordinate Transformation after Cropping

· 3 · 6542
*

Marvin Wolf

  • *
  • Posts: 5
    • View Profile
Coordinate Transformation after Cropping
« on: June 14, 2021, 11:30:12 AM »
Hello,

I am currently analysing a micro-CT Scan of a woven fabric. Therefore I have to manually cut out single rovings using ProcessGeo -> Crop. Subsequently I want to determine the coordinates of the centroids for every single slice of the roving-cut.
When using ProcessGeo->Crop, a new coordinate-system is introduced ("local" concerning the roving-cut). The determined centroid coordinates refer to this local coordinate-system. However, I am interested in the "global" coordinates of the centroid. Global in this case means reffering to the coordinate-system of the whole micro-Ct Scan. I am searching for a possibility to transfer the "local" coordinates to the "global" coordinate-system.

My Idea was to save the Crop-Settings when cutting out the roving and later use the number of voxel I cutted to perform the coordinate-transformation. The Crop-Settings are saved as a .gps file. Is there a way to read the number of voxel I cutted from this .gps file? As my analysis regards many rovings, it would be helpful if a Macro could read the mentioned voxel-number so that I am able to perform the coordinate transformation using Python.

Thank you for your answer.

Kind regards
Marvin

*

Aaron Widera

  • Math2Market Employee
  • *****
  • Posts: 63
    • View Profile
    • Math2Market GmbH
  • Position: Sales Engineer Digital Material R&D
Re: Coordinate Transformation after Cropping
« Reply #1 on: June 16, 2021, 05:52:05 PM »
Hi Marvin,

yes such a transformation is possible with python and know how ProcessGeo Crop saves the settings to the gps file.

As an example say you have a 200x300x400 (X x Y x Z) structure with a voxel length of 2 µm. And you are looking at the X-Y Plane for the Coordination investigation.
Now you crop the structure in X direction for 20 voxel from the lower sider and 50 voxel from the higher side. That means the X direction is 70 voxels shorter (so it has 130 voxels in total).
Similar you crop the structure in Y direction for 30 voxel from the lower sider and 60 voxel from the higher side. That means the X direction is 90 voxels shorter (so it has 210 voxels in total).
This would mean that the X-Y Coordinates of your new Origin are at 40 µm x 60 µm of your old Origin.
The corresponding ProcessGeo Crop gps looks like:
Code: [Select]
  <ProcessGeo>
    <Crop>
      XMinus 20
      XPlus  50
      YMinus 30
      YPlus  60
      ZMinus 0
      ZPlus  0
    </Crop>
  </ProcessGeo>
So when you obtain coordiantes from the new system X' and Y' you can transform them back to the old system by:
\( X_{old} = X' - 20 * 2 µm \) and \( Y_{old} = Y' - 30 * 2 µm \)
This you can automate by using GeoPython to access the Crop Seetings, here is a small example code:
Code: [Select]
import stringmap

x_new = 1.04*1e-4
y_new = 1.56*1e-4
voxellength = 2*1e-6
gpsMap = stringmap.parseGDR('PathToGPSFile/File.gps')
x_crop = gpsMap.get('ProcessGeo:Crop:XMinus')
y_crop = gpsMap.get('ProcessGeo:Crop:YMinus')

x_trans = x_new + x_crop*voxellength
y_trans = y_new + y_crop*voxellength
In this example your x and y coordiante values in the new system are 104 µm which is 1.04e-4 m and 156 µm which is 1.56e-4 m.
And this code extracts the cropped value in x and y direction and uses it to transform the coordinates into the original coordiante system. Those coordinates are saved in the variable x_trans and y_trans

I hope that help, otherwise I will answer follow up questions.

*

Marvin Wolf

  • *
  • Posts: 5
    • View Profile
Re: Coordinate Transformation after Cropping
« Reply #2 on: June 21, 2021, 10:32:52 AM »
Hi Aaron,

thank you for your detailed answer. The coordinate transformation worked for me, the information about how ProcessGeo Crop saves the data in the gps file was the key information.

Kind regards
Marvin