y.append(1 - tmr_arr[it9]) return y def syndrome_fix(syndrome_vector_noised): index_to_fix = -1 if np.array_equal(syndrome_vector_noised, np.zeros((4, ), dtype=int)): return -1 for columnIt in range(0, len(H)): if np.array_equal(syndrome_vector_noised, H.T[columnIt]): index_to_fix = columnIt return index_to_fix image = cv2.imread("outFile_ITL_Gilbert_2.png", 1) x = ldpc_images.RGB2Bin(image) y = np.zeros_like(x) input_data = np.zeros((4, ), dtype=int) it3 = 0 main_error_counter = 0 for it in range(len(x)): for it2 in range(len(x[it])): it3 = 0 while it3 < len(x[it][it2]): input_data = np.copy(x[it][it2][it3:it3 + 4]) data_vector = np.dot(input_data, G) % 2 # Calculated input data vector noised_data = np.asarray(gilbert_noise(
if current_state == 'G': if np.random.random() < p_gb: # symulacja zmiany stanu z prawdopodobienstwiem pDZ current_state = 'B' # zmiana stanu y[it][it2][it3] = x[it][it2][it3] elif current_state == 'B': if np.random.random() < p_bg: current_state = 'G' y[it][it2][it3] = 1 - x[it][it2][it3] it2 += x_iterator it2 = 0 current_state = 'G' it += y_iterator counter += 1 it = 0 if counter % 2 == 0: x_iterator = x_iterator // 2 else: y_iterator = y_iterator // 2 return y image = cv2.imread("inFile.png", 1) image_arr = ldpc_images.RGB2Bin(image) hamming_arr = np.zeros_like(image_arr) # hamming_arr = bsc_noise(image_arr, hamming_arr) hamming_arr = gilbert_noise(image_arr, hamming_arr) image_final = ldpc_images.Bin2RGB(hamming_arr) cv2.imwrite("outFileITL.png", image_final)