You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you so much for your code.
I don't understand this line: sub = self.segments[i:i + 2, j:j + 2]
Could you please explain how to judge if the two superpixels share a common boundary?
`
def get_A(self, sigma: float):
'''
根据 segments 判定邻接矩阵
:return:
'''
A = np.zeros([self.superpixel_count, self.superpixel_count], dtype=np.float32)
(h, w) = self.segments.shape
for i in range(h - 2):
for j in range(w - 2):
sub = self.segments[i:i + 2, j:j + 2]
sub_max = np.max(sub).astype(np.int32)
sub_min = np.min(sub).astype(np.int32)
# if len(sub_set)>1:
if sub_max != sub_min:
idx1 = sub_max
idx2 = sub_min
if A[idx1, idx2] != 0:
continue
Thanks. In fact, I adopted a very simple suboptimal solution. I used a very small window (2x2 or 3x3)to detect the boundaries, i.e., if the classes of pixels in this window exceed 2, then it must be on the boundary. Just like the edge detector.
Thank you so much for your code.
I don't understand this line: sub = self.segments[i:i + 2, j:j + 2]
Could you please explain how to judge if the two superpixels share a common boundary?
`
def get_A(self, sigma: float):
'''
根据 segments 判定邻接矩阵
:return:
'''
A = np.zeros([self.superpixel_count, self.superpixel_count], dtype=np.float32)
(h, w) = self.segments.shape
for i in range(h - 2):
for j in range(w - 2):
sub = self.segments[i:i + 2, j:j + 2]
sub_max = np.max(sub).astype(np.int32)
sub_min = np.min(sub).astype(np.int32)
# if len(sub_set)>1:
if sub_max != sub_min:
idx1 = sub_max
idx2 = sub_min
if A[idx1, idx2] != 0:
continue
`
The text was updated successfully, but these errors were encountered: