def compute_histograms(image_list, hist_type, hist_isgray, num_bins):

    image_hist = []

    # compute hisgoram for each image and add it at the bottom of image_hist
    # your code here
    for i in range(len(image_list)):
        images = np.array(Image.open(image_list[i]))
        images = images.astype('double')

        if hist_isgray:
            image_gray = rgb2gray(images)
            hist = histogram_module.get_hist_by_name(image_gray, num_bins,
                                                     hist_type)
        else:
            hist = histogram_module.get_hist_by_name(images, num_bins,
                                                     hist_type)

        # print(len(hist))
        if len(hist) == 2 and len(hist[0]) > 1:
            hist = hist[0]

        image_hist.append(hist)

    return image_hist
Esempio n. 2
0
def compute_histograms(image_list, hist_type, hist_isgray, num_bins):

    image_hist = []

    # Compute hisgoram for each image and add it at the bottom of image_hist

    for image_path in image_list:

        image = np.array(Image.open(image_path)).astype('double')
        if hist_isgray:
            image = rgb2gray(image)

        if hist_type == "grayvalue":
            hists, _ = histogram_module.get_hist_by_name(
                image, num_bins, hist_type)
        else:
            hists = histogram_module.get_hist_by_name(image, num_bins,
                                                      hist_type)
        image_hist.append(hists)

    return image_hist
Esempio n. 3
0
def compute_histograms(image_list, hist_type, hist_isgray, num_bins):

    image_hist = []

    for i in range(len(image_list)):
        img = (np.array(Image.open(image_list[i]))).astype('double')
        if (hist_type == 'dxdy'):
            img = rgb2gray(img)
        hist = histogram_module.get_hist_by_name(img, num_bins, hist_type)
        image_hist.append(hist)

    return image_hist
Esempio n. 4
0
def compute_histograms(image_list, hist_type, hist_isgray, num_bins):
    
    image_hist = []

    # Compute hisgoram for each image and add it at the bottom of image_hist

    for i in image_list:
        img = np.array(Image.open(os.path.join(THIS_FOLDER, i)), float)
        if hist_isgray:
            img = rgb2gray(img)
        image_hist.append(histogram_module.get_hist_by_name(img, num_bins, hist_type))

    return image_hist
Esempio n. 5
0
def single_hist_maker(img, hist_type, hist_isgray, num_bins):
    # Gray or colored image
    if hist_isgray == True:
        img = rgb2gray(np.array(Image.open(img)))
    else:
        img = np.array(Image.open(img))
    # Histogram type
    hist = histogram_module.get_hist_by_name(np.array(img, float), num_bins,
                                             hist_type)
    if hist_type == 'grayvalue':
        return hist[0]
    else:
        return hist
def compute_histograms(image_list, hist_type, hist_isgray, num_bins):

    image_hist = []

    # compute hisgoram for each image and add it at the bottom of image_hist

    if hist_isgray:
        for name in image_list:
            img = Image.open('./' + name)
            arr_img = np.array(img, dtype=float)
            img_gray = rgb2gray(arr_img)
            hist, _ = histogram_module.get_hist_by_name(
                img_gray, num_bins, hist_type).tolist()
            image_hist.append(hist.tolist())
    else:
        for name in image_list:
            img = Image.open('./' + name)
            arr = np.array(img, dtype=float)
            hist = histogram_module.get_hist_by_name(arr, num_bins,
                                                     hist_type).tolist()
            image_hist.append(hist)

    return image_hist
Esempio n. 7
0
def compute_histograms(image_list, hist_type, hist_isgray, num_bins):

    image_hist = []

    # compute histogram for each image and add it at the bottom of image_hist
    # your code here
    for image_name in image_list:
        image = np.array(Image.open(image_name)).astype('double')
        if hist_isgray:
            image = rgb2gray(image)

        image_hist.append(histogram_module.get_hist_by_name(
            image, num_bins, hist_type))

    return image_hist
Esempio n. 8
0
def compute_histograms(image_list, hist_type, hist_isgray, num_bins):
    image_hist = []

    # Compute histogram for each image and add it at the bottom of image_hist
    # ... (your code here)
    for image in image_list:
        if hist_isgray:
            img_color = np.array(Image.open(image))
            img = rgb2gray(img_color.astype('double'))
        else:
            img = np.array(Image.open(image)).astype('double')

        hist = histogram_module.get_hist_by_name(img, num_bins, hist_type)

        image_hist.append(hist)

    return image_hist
def compute_histograms(image_list, hist_type, hist_isgray, num_bins):

    image_hist = []

    for img in image_list:
        img = np.array(Image.open(img)).astype('double')

        if hist_isgray:
            img = rgb2gray(img)

        hist = histogram_module.get_hist_by_name(img, num_bins, hist_type)

        if len(hist) == 2:
            hist = hist[0]

        image_hist.append(hist)

    return image_hist
Esempio n. 10
0
def compute_histograms(image_list, hist_type, hist_isgray, num_bins):

    image_hist = []

    # Compute hisgoram for each image and add it at the bottom of image_hist

    for i in range(len(image_list)):
        img = np.array(Image.open("./" + image_list[i]))
        img = img.astype('double')
        if hist_isgray:
            img = rgb2gray(img)
        hist = histogram_module.get_hist_by_name(img, num_bins, hist_type)

        if len(hist) == 2:
            hist = hist[0]

        image_hist.append(hist)

    return image_hist
Esempio n. 11
0
def compute_histograms(image_list, hist_type, hist_isgray, num_bins):
    
    image_hist = []

    # Compute hisgoram for each image and add it at the bottom of image_hist

    image_hist = []
    
    for i in range(len(image_list)):
        img= np.array(Image.open(image_list[i]))

        if histogram_module.is_grayvalue_hist(hist_type)==False:        
            img= img.astype('double')
            
        elif histogram_module.is_grayvalue_hist(hist_type)==True:
            img = rgb2gray(img.astype('double'))
            
        hist = histogram_module.get_hist_by_name(img, num_bins, hist_type)
        if len(hist) == 2: # !!!important  the normalized histogram(greyvalue name) function returns the bins too, so they are cut at this part
            hist = hist[0]
        image_hist.append(hist)


    return image_hist
Esempio n. 12
0
    img1_color = img1_color.astype('double')
    img1_gray = rgb2gray(img1_color)

    for img2_file in image_files2:
        img2_color = np.array(Image.open(img2_file))
        img2_color = img2_color.astype('double')
        img2_gray = rgb2gray(img2_color)

        D = np.zeros((len(distance_types), len(hist_types)))

        for didx in range(len(distance_types)):

            for hidx in range(len(hist_types)):

                if histogram_module.is_grayvalue_hist(hist_types[hidx]):
                    hist1 = histogram_module.get_hist_by_name(
                        img1_gray, num_bins_gray, hist_types[hidx])
                    hist2 = histogram_module.get_hist_by_name(
                        img2_gray, num_bins_gray, hist_types[hidx])

                else:
                    hist1 = histogram_module.get_hist_by_name(
                        img1_color, num_bins_color, hist_types[hidx])
                    hist2 = histogram_module.get_hist_by_name(
                        img2_color, num_bins_color, hist_types[hidx])

                if len(hist1) == 2:
                    hist1 = hist1[0]
                if len(hist2) == 2:
                    hist2 = hist2[0]

                D[didx,