@@ -924,16 +924,23 @@ def set_image(self, img: np.ndarray):
924924
925925 def get_points (self ):
926926 """Get all selected points from manual and polygons."""
927- points = np .array (self .selected_points )[:, ::- 1 ] # set axis 0 to y and axis 1 to x
928- return points
927+ filtered_points = self .get_filtered_points ()
928+ if filtered_points .size > 0 :
929+ return filtered_points
930+ else :
931+ return self .get_selected_points ()
929932
930933 @property
931934 def points (self ):
932935 return self .get_points ()
933936
934937 def get_filtered_points (self ):
935- """Get candidate points from automatic filtering."""
936- return self .candidate_points .copy () if hasattr (self , 'candidate_points' ) else []
938+ """Get candidate points from filtering."""
939+ return np .array (self .candidate_points )[:, ::- 1 ] if hasattr (self , 'candidate_points' ) else []
940+
941+ def get_selected_points (self ):
942+ """Get all selected points from manual, polygons and grid."""
943+ return np .array (self .selected_points )[:, ::- 1 ] if self .selected_points else []
937944
938945 # Grid selection
939946 def handle_grid_drawing (self , event ):
@@ -1160,7 +1167,7 @@ def update_threshold_and_show_shi_tomsi(self):
11601167
11611168 eig_threshold = self .max_eig_shi_tomasi * threshold_ratio
11621169
1163- self .candidate_points = [(round (y )+ 0.5 , round (x )+ 0.5 ) for (x , y , e ) in self .candidates_shi_tomasi if e > eig_threshold ]
1170+ self .candidate_points = [(round (y ), round (x )) for (x , y , e ) in self .candidates_shi_tomasi if e > eig_threshold ]
11641171 self .update_candidate_display ()
11651172 self .update_candidate_points_count ()
11661173
@@ -1185,7 +1192,7 @@ def update_candidate_display(self):
11851192 self .view .addItem (self .candidate_scatter )
11861193
11871194 if self .candidate_points :
1188- self .candidate_scatter .setData (pos = self .candidate_points )
1195+ self .candidate_scatter .setData (pos = np . array ( self .candidate_points ) + 0.5 )
11891196 else :
11901197 self .candidate_scatter .clear ()
11911198
@@ -1277,7 +1284,7 @@ def update_threshold_and_show_gradient_direction(self):
12771284 threshold = self .max_grad_dir * threshold_ratio
12781285
12791286 self .candidate_points = [
1280- (round (y )+ 0.5 , round (x )+ 0.5 )
1287+ (round (y ), round (x ))
12811288 for (x , y , v ) in self .candidates_grad_dir
12821289 if v > threshold
12831290 ]
0 commit comments