Skip to content
Snippets Groups Projects
Commit aaeff027 authored by Levecque Etienne's avatar Levecque Etienne
Browse files

feat: improve behavior of clipped blocks

If avoid_clipped is True, the algorithm will not run on clipped block, they will not appear in the outputs.csv
Otherwise, the algorithm will search antecedent of clipped blocks with the search upper bound multiplied by 2.
parent 6f4691ed
No related branches found
No related tags found
No related merge requests found
......@@ -189,8 +189,6 @@ class Image:
def filter_blocks(self, purge=False):
if self.is_filtered and not purge:
return
if not self.avoid_clipped and not purge:
return
is_pixel = not self.is_jpeg
backward_blocks = np.copy(self.block_view).reshape(-1, self.channel, 8, 8) # List of blocks (None, c, 8, 8)
......@@ -210,11 +208,16 @@ class Image:
self.is_filtered = True
return clip_mask
def select_blocks(self, purge=False, ignore_clipped=False):
def select_blocks(self, purge=False):
if np.any(self.selected_blocks) and not purge:
return self.selected_blocks
blocks = [b for _, b in self.block_collection.items() if
not (self.avoid_clipped and b.is_clipped[self.pipeline])]
if self.selection_percentage == 100:
self.selected_blocks = blocks
return self.selected_blocks
blocks = [b for _, b in self.block_collection.items() if not (ignore_clipped and b.is_clipped[self.pipeline])]
n = min(int(len(self.block_collection) * self.selection_percentage / 100), len(blocks))
if self.method_name == 'random':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment