Skip to content
Snippets Groups Projects
Commit 773080b7 authored by Francois POLACK's avatar Francois POLACK
Browse files

feat: Added Heightmap clipping and ability to flip the recorded view when

	data are acquired upside down
parent 5f107453
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,7 @@ class ROItool(ToolBase):
# self.figure.hmap.ROIorigin=[self.figure.ROI[0],self.figure.ROI[1]]
# self.figure.hmap.ROIsize=[self.figure.ROI[2],self.figure.ROI[3]]
#print("saving ROI:",self.figure.ROI)
#print("ROI defined")
print("ROI defined from figure")
plt.close(self.figure)
......
......@@ -69,6 +69,8 @@ class HeightMap(object):
self.ROIorigin=[0,0]
## (int, int) Size of the ROI in pixels (this is the size of Z, ze ... arrayss)
self.ROIsize=[0,0]
## an integer or a twoplet indicating the axis which must be reverted
self.flipROI=None
## Number of invalid values in the ROI
self.num_invalid=0
## Original fullsize height data loaded from the file.
......@@ -446,19 +448,28 @@ class HeightMap(object):
format(title_y, np.ma.std(uu) * mult, unit, (vbounds[1] - vbounds[0]) * mult, unit))
# end print_statistics
def clip(self, origin, size):
self.rawZ=self.rawZ[origin[1]:origin[1]+size[1], origin[0]:origin[0]+size[0]]
def set_ROI(self, firstX, firstY, nwidth, nheight):
def set_ROI(self, firstX, firstY, nwidth, nheight, flip=None):
"""! define a rectangular ROI and set the `HeightMap.z`array accordingly
@param firstX origin of the ROI in x (pixels from `HeightMap.origin`)\n
@param firstY origin of the ROI in y (pixels from `HeightMap.origin`)\n
@param nwidth width of the ROI (pixels)
@param nheight height of the ROI (pixels)
@param flip int or tuple indicating the axes to flip
"""
self.ROIorigin=[firstX, firstY]
self.ROIsize=[nwidth, nheight]
if flip!=None:
self.flipROI=flip
self.z=self.rawZ[firstY:firstY+nheight, firstX:firstX+nwidth]
print("\n ROI definition:")
if self.flipROI==None:
self.z=self.rawZ[firstY:firstY+nheight, firstX:firstX+nwidth]
else:
self.z=np.flip(self.rawZ[firstY:firstY+nheight, firstX:firstX+nwidth],self.flipROI)
print("ROI axes", self.flipROI, "are flipped over")
print("original size ", self.rawZ.shape, " ROI size " , self.z.shape)
self.set_scale((self.origin[0]+firstX,self.origin[1]+firstY))
#end set_ROI
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment