[docs]classFragileBitRefinement(Algorithm):"""Refining mask by masking out fragile bits. Algorithm: Thresholding by the given parameter value_threshold at each bit, set the corresponding mask response to 0 if iris response is below the threshold. """
__parameters_type__=Parametersdef__init__(self,value_threshold:Tuple[confloat(ge=0),confloat(ge=0)],fragile_type:Literal["cartesian","polar"]="polar",)->None:"""Create Fragile Bit Refinement object. Args: value_threshold (Tuple[confloat(ge=0), confloat(ge=0)]): Thresholding iris response values. fragile_type (Literal["cartesian", "polar"], optional): The Fragile bits can be either calculated in cartesian or polar coordinates. In the first, the values of value_threshold denote to x and y axis, in the case of polar coordinates, the values denote to radius and angle. Defaults to "polar". """super().__init__(value_threshold=value_threshold,fragile_type=fragile_type)
[docs]defrun(self,iris_filter_response:IrisFilterResponse)->IrisFilterResponse:"""Generate refined IrisFilterResponse. Args: iris_filter_response (IrisFilterResponse): Filter bank response. Returns: IrisFilterResponse: Filter bank response. """fragile_masks=[]foriris_response,iris_maskinzip(iris_filter_response.iris_responses,iris_filter_response.mask_responses):ifself.params.fragile_type=="cartesian":mask_value_real=np.abs(np.real(iris_response))>=self.params.value_threshold[0]mask_value_imaginary=np.abs(np.imag(iris_response))>=self.params.value_threshold[1]mask_value=mask_value_real*mask_value_imaginaryifself.params.fragile_type=="polar":iris_response_r=np.abs(iris_response)iris_response_phi=np.angle(iris_response)mask_value_r=iris_response_r>=self.params.value_threshold[0]cos_mask=np.abs(np.cos(iris_response_phi))<=np.abs(np.cos(self.params.value_threshold[1]))sine_mask=np.abs(np.sin(iris_response_phi))<=np.abs(np.cos(self.params.value_threshold[1]))mask_value_phi=cos_mask*sine_maskmask_value=mask_value_r*mask_value_phimask_value=mask_value*iris_maskfragile_masks.append(mask_value)returnIrisFilterResponse(iris_responses=iris_filter_response.iris_responses,mask_responses=fragile_masks,iris_code_version=iris_filter_response.iris_code_version,)