def formula2(mattrix_img_blue, mattrix_img_red, mattrix_img_green, col, row): mattrix_img_new = copy(mattrix_img_blue) for i in range(row): for j in range(col): mattrix_img_new[i][j] = mattrix_img_red[i][j] - \ mattrix_img_blue[i][j] mattrix_img_new[i][j] = checklimit(mattrix_img_new[i][j]) return mattrix_img_new
def formula3(mattrix_img_blue, mattrix_img_red, mattrix_img_green, col, row): mattrix_img_new = copy(mattrix_img_blue) for i in range(row): for j in range(col): mattrix_img_new[i][j] = int( (mattrix_img_green[i][j] + mattrix_img_red[i][j] + mattrix_img_blue[i][j]) / 3) mattrix_img_new[i][j] = checklimit(mattrix_img_new[i][j]) return mattrix_img_new
y[3] = grid[i + 1][j + 1][1] for k in range(4): xy[k][0] = x[k] xy[k][1] = y[k] xy[k][2] = x[k] * y[k] xy[k][3] = 1 x_dist[0] = dist[i][j][0] x_dist[1] = dist[i][j + 1][0] x_dist[2] = dist[i + 1][j][0] x_dist[3] = dist[i + 1][j + 1][0] y_dist[0] = dist[i][j][1] y_dist[1] = dist[i][j + 1][1] y_dist[2] = dist[i + 1][j][1] y_dist[3] = dist[i + 1][j + 1][1] xy_new1 = copy(xy) xy_new2 = copy(xy) w1_to_4 = solve4eqaultion(xy_new1, x_dist) w5_to_8 = solve4eqaultion(xy_new2, y_dist) for k in range(len(w1_to_4)): w[k] = w1_to_4[k] for k in range(len(w5_to_8)): w[k + 4] = w5_to_8[k] for k in range(y[0], y[2]): for l in range(x[0], x[1]): xp = (w[0] * l + w[1] * k + w[2] * l * k + w[3]) yp = (w[4] * l + w[5] * k + w[6] * l * k + w[7]) image_new[k][l] = Bilinear(mattrix_img, yp, xp) writepgm("new_lenna.pgm", image_new, col, row)
count = 0 histogram = createHistogram(converted_img) # count object for key in histogram: if histogram[key] > 1500 and key != 255: object_dict[key] = histogram.get(key) count = count + 1 print("Histogram of image :") print(histogram) print("Number of Object : " + str(count)) print("Gray level of each object") print(object_dict) maskesOb_img = copy(mattrix_img) for key in object_dict: for i in range(row): for j in range(col): if mattrix_img[i][j] == key: maskesOb_img[i][j] = 1 else: maskesOb_img[i][j] = 0 U20 = pqHu(2, 0, maskesOb_img, row, col) U02 = pqHu(0, 2, maskesOb_img, row, col) N20 = pqN(2, 0, maskesOb_img, row, col) N02 = pqN(0, 2, maskesOb_img, row, col)
if histogram[key] > 1500 and key != 255: object_dict[key] = histogram.get(key) count = count + 1 print("Histogram of image :") print(histogram) print("Number of Object : " + str(count)) print("Gray level of each object") obj = 0 for key in object_dict: obj += 1 print("Gray level of Object " + str(obj) + " is " + str(key)) obj = 0 Object = copy(mattrix_img) for key in object_dict: for i in range(row): for j in range(col): if mattrix_img[i][j] == key: Object[i][j] = 1 else: Object[i][j] = 0 U20 = pqHu(2, 0, Object, row, col) U02 = pqHu(0, 2, Object, row, col) N20 = pqN(2, 0, Object, row, col) N02 = pqN(0, 2, Object, row, col) theata = N20 + N02