def bilteralFiltering(threadName,img_Eq,param1,param2,sigma): img_filtered_list.append(img_as_ubyte(frangi(cv2.bilateralFilter(img_Eq,param1,param2,param2),sigma[0] ,sigma[1] ,0.5,0.125, True)))
def runFrangi(filtered_images,sigma_x,sigma_y,beta1,beta2,black_ridges=True): img_fr = img_as_ubyte(frangi(filtered_images,sigma_x ,sigma_y ,beta1,beta2, black_ridges)) return img_fr
def perform_eCS_algorithm(img_in, sigma_x=1.0, sigma_y=1.0, angle=0.0, mask_fft=np.zeros((0))): """ Perform eCS algorithm described in: Enhanced Crack Segmentation (eCS): A Reference Algorithm for Segmenting Cracks in Multicrystalline Silicon Solar Cells Parameters ---------- img_in : ndarray Input image. angle : float Rotation angle in degrees in counter-clockwise direction. sigma_x : float Gaussian filter sigma in x-direction sigma_y: float Gaussian filter sigma in y-direction mask_fft : ndarray mask for fft filtering to get rid of grid fingers Returns ------- img_result : ndarray processed image """ if (mask_fft.size != 0): img_in = fft(img_in, mask_fft) img_equalized = cv2.equalizeHist(img_in) img_roi = createROI(img_equalized) plt.figure() #plt.imshow(img_roi) - Good estimation of ROI. Implement in dataArtist img_smoothed = cv2.bilateralFilter(img_equalized, 3, 25, 25) if angle != 0.0: img_smoothed = rotate(img_smoothed, angle, resize=True, preserve_range=True) img_result = img_as_ubyte( frangi(img_smoothed, sigma_x=sigma_x, sigma_y=sigma_y, beta1=0.5, beta2=0.05, black_ridges=True)) if (sigma_x != sigma_y): img_y = img_as_ubyte( frangi(img_smoothed, sigma_x=sigma_y, sigma_y=sigma_x, beta1=0.5, beta2=0.05, black_ridges=True)) img_result = np.maximum(img_result, img_y) if angle != 0.0: #Modified to handel rect img of diff sizes with np.shape w = img_result.shape[0] w_org = img_in.shape[0] #changed to higt and width offset = (w - w_org) // 2 h_org = img_in.shape[1] #img is rotated back, and scaled to right size img_result = rotate(img_result, -angle, resize=True, preserve_range=True)[offset:offset + w_org, offset:offset + h_org] img_result = img_result * img_roi return img_result.astype( 'float32') #does this need to be float32? can unit8?
#Bilateral img_filtered = cv2.bilateralFilter(img_Eq, param_bl[0][i], param_bl[1][j], param_bl[1][j]) #apply frangi for different scales for t in range(len(param_beta1)): for z in range(len(param_beta2)): v = [] for k in range(len(param_x)): for l in range(len(param_y)): v.append( img_as_ubyte( frangi(img_filtered, sigma_x=param_x[k], sigma_y=param_y[l], beta1=param_beta1[t], beta2=param_beta2[z], black_ridges=True))) img_fr = v[0] for sigma_index in range(len(v) - 1): img_fr = np.minimum(img_fr, v[sigma_index + 1]) img_fr = img_fr * img_roi ''' this part of the code applies old algorithm to get rid of unwanted shapes may be I can delete this part later ''' #img_fr.astype(np.float32) _, img_thresh = cv2.threshold( img_fr, 3, 255, cv2.THRESH_BINARY) # y-axes