Ejemplo n.º 1
0
def main(args):
    image_dir = ir.get_image_dir()
    color_space = ir.get_color_space()
    image_paths = ir.get_image_files(image_dir)
    images = [pil.open(img) for img in image_paths]

    print("================ Task I ================")
    task_I.median_cut_histogram(images, color_space)

    print("================ Task II ================")
    image, image_id = ir.get_image()
    task_II.histogram_generator(image, image_id, color_space)

    print("================ Task III ================")
    image, image_id = ir.get_image()
    task_III.dct_freq(image, image_id, color_space)

    print("================ Task IV ================")
    image, image_id = ir.get_image()
    task_IV.do_task_4(image, image_id, color_space)

    print("================ Task V ================")
    image, image_id = ir.get_image()
    task_V.do_task_5(image, image_id, color_space)

    print("================ Task VI ================")
    image, image_id = ir.get_image()
    task_VI.dwt_freq(image, image_id, color_space)

    print("================ Task VII ================")
    response = batch_option()
    if response == 'y':
        batch_dir = ir.get_image_dir()
        process_batch(batch_dir)
Ejemplo n.º 2
0
def query_region():
    image, image_id = get_image()
    width, height = image.size
    
    new_height = int(ceil(height / 8))#cells in a column
    new_width = int(ceil(width / 8))#cells in a row
    print("================ Task II ================")
    ihist = task_II.histogram_generator(image, image_id, color_space)
    
    print("================ Task III ================")
    idct = task_III.dct_freq(image, image_id, color_space)
    
    print("================ Task IV ================")
    iangle = task_IV.do_task_4(image, image_id, color_space)
	
    print("================ Task V ================")
    iamp = task_V.do_task_5(image, image_id, color_space)
	
    print("================ Task VI ================")
    idwt = task_VI.dwt_freq(image, image_id, color_space)
    
    #retrieve cell_coord top left
    coord = raw_input("Enter the coordinate ID for the top left cell in desired query region:  ")
    #retrieve 9 cells
    qr = []
    
    # this gets our <0,0> for the region
    # row :  if x coord > # of cells in (row - 2), then x(an index #)= row.length -3 (account for index = 0)
    
    if coord % new_width >= (new_width - 2):
        x = new_width - 3
    else:
        x = coord % new_width
    if coord // new_height >= (new_height - 2):
        y = new_height - 3
    else:
        y = coord // new_height    
    coord = x + new_width *y
    
    for y in range (3):
        for x in range (3):
            qr.append(coord + x + (new_width * y))  #now we have a list of 3 x 3 coord_ids
            
    #using general historgram spec from task one
    histospec = get_histogram_spec()
    
    #need to get features of SELECTED COORDINATE CELLS from the lists created above.
    #each list above ids the coordinate by the index of the list item
    #simply need to referecne the coordinate id to get from ea list above
    cellinfo = []
    for index, coord in qr:
        cellinfoname = str(coord)  #uniquely name the dictionary of features
        cellinfoname = {'histogram': ihist[coord], 'dct': idct[coord], 'angle': iangle[coord], 'amplitude': iamp[coord], 'dwt': idwt[coord]}
        cellinfo[index] = cellinfoname  #should place a dictionary in each index of cellinfo