from readpgm import read_pgm, list_to_2D_list, copy from etc_function import solve4eqaultion, Bilinear from dist_list import disgrid, grid from writepgm import writepgm filename = "./image/4./distlenna.pgm" # filename = "./image/4./distgrid.pgm" col = 0 row = 0 mattrix_img = [] listimg, col, row = read_pgm(filename, col, row) mattrix_img = list_to_2D_list(listimg, mattrix_img, col, row) grid = grid() dist = disgrid() x = [0] * 4 y = [0] * 4 w1_to_4 = [0] * 4 w5_to_8 = [0] * 4 w = [0] * 8 x_dist = [0] * 4 y_dist = [0] * 4 xy = [] Am = [] x_vertor_dist = [0] * 4 for i in range(4): xy_in_loop = [] Am_in_loop = [] for j in range(4): xy_in_loop.append(0)
from readpgm import read_pgm, list_to_2D_list, copy from writepgm import writepgm from etc_function import createHistogram file_Lenna = "./image/4_/distlenna.pgm" converted_img_Lenna = [] mattrix_FalseGrid = [] mattrix_TrueGrid = [] mattrix_Lenna = [] col = 0 row = 0 converted_img_Lenna, col, row = read_pgm(file_Lenna, col, row) mattrix_Lenna = list_to_2D_list(converted_img_Lenna, mattrix_Lenna, col, row) mattrix_TrueGrid = mattrix_Lenna # mattrix_TrueGrid have gray level 0 at cutting point 255 otherwise for i in range(len(mattrix_TrueGrid)): for j in range(len(mattrix_TrueGrid[i])): mattrix_TrueGrid[i][j] = 255 for i in range(len(mattrix_TrueGrid)): for j in range(len(mattrix_TrueGrid[i])): if (((j != 0) and (j % 16) == 0)): if (((i + 1) % 16) == 0): mattrix_TrueGrid[i][j] = 0 elif (j == 0): if ((i % 16) == 0 or (i == 0)): mattrix_TrueGrid[i][j] = 0 # cutting point from FalseGrid disgrid = [[[0, 0], [16, 0], [32, 0], [48, 0], [64, 0], [80, 0], [96, 0], [112, 0], [128, 0], [144, 0], [160, 0], [176, 0], [192, 0], [208, 0], [224, 0], [240, 0], [255, 0]],
from readpgm import read_pgm, list_to_2D_list, copy from momentFunction import pqmoment, pqN, pqHu from etc_function import createHistogram filename = "./image/1./scaled_shapes.pgm" converted_img = [] mattrix_img = [] col = 0 row = 0 converted_img, col, row = read_pgm(filename, col, row) mattrix_img = list_to_2D_list(converted_img, mattrix_img, col, row) object_dict = {} 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:
from writepgm import writepgm from etc_function import createHistogram fileBlue = "./image/3_/SanFranPeak_blue.pgm" fileRed = "./image/3_/SanFranPeak_red.pgm" fileGreen = "./image/3_/SanFranPeak_green.pgm" converted_img_Blue = [] converted_img_Red = [] converted_img_Green = [] mattrix_img_Blue = [] mattrix_img_Red = [] mattrix_img_Green = [] col = 0 row = 0 converted_img_Blue, col, row = read_pgm(fileBlue, col, row) converted_img_Red, col, row = read_pgm(fileRed, col, row) converted_img_Green, col, row = read_pgm(fileGreen, col, row) mattrix_img_Blue = list_to_2D_list(converted_img_Blue, mattrix_img_Blue, col, row) mattrix_img_Red = list_to_2D_list(converted_img_Red, mattrix_img_Red, col, row) mattrix_img_Green = list_to_2D_list(converted_img_Green, mattrix_img_Green, col, row) mattrix_img_Result = mattrix_img_Blue for i in range(len(mattrix_img_Blue)): # mixed color for j in range(len(mattrix_img_Blue[i])): template = (mattrix_img_Blue[i][j] + mattrix_img_Red[i][j] + mattrix_img_Green[i][j]) / 3 template2 = int(template) if (template - template2) >= 0.5:
from readpgm import read_pgm filename = "./image/1_/scaled_shapes.pgm" col = 0 row = 0 img, col, row = read_pgm(filename, col, row) img2 = read_pgm(filename, col, row) # print(img[2])
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 filename_blue = "./image/3./SanFranPeak_blue.pgm" filename_red = "./image/3./SanFranPeak_red.pgm" filename_green = "./image/3./SanFranPeak_green.pgm" col = 0 row = 0 mattrix_img_red = [] mattrix_img_green = [] mattrix_img_blue = [] listimg_red, col, row = read_pgm(filename_red, col, row) listimg_green, col, row = read_pgm(filename_blue, col, row) listimg_blue, col, row = read_pgm(filename_green, col, row) mattrix_img_red = list_to_2D_list(listimg_red, mattrix_img_red, col, row) mattrix_img_blue = list_to_2D_list(listimg_blue, mattrix_img_blue, col, row) mattrix_img_green = list_to_2D_list(listimg_green, mattrix_img_green, col, row) exceedgreen = formula1(mattrix_img_blue, mattrix_img_red, mattrix_img_green, col, row) red_blue_diff = formula2(mattrix_img_blue, mattrix_img_red, mattrix_img_green, col, row) intensity = formula3(mattrix_img_blue, mattrix_img_red, mattrix_img_green, col, row)