예제 #1
0
            b[x][y] = min(R[col2bin(original[x][y], (bins,bins,bins))], 1)
    return b

# Determine color model
if len(argv) <= 1 or (len(argv) > 1 and argv[1] not in('RGB', 'HSV', 'HSL')):
    print "No valid color model provided, choosing RGB"
    colormodel = 'RGB'
else:
    print "Color model %s provided" % (argv[1])
    colormodel = argv[1]

original = imread('waldo/waldo_env.tiff') / 255.0
to_find = imread('waldo/waldo.tiff') / 255.0

print "Calculating Histograms"
I = colHist(original, (bins, bins, bins), colormodel)
M = colHist(to_find, (bins, bins, bins), colormodel)
R = calculate_R(I, M, bins)

print "Creating Backprojection"
b = create_b(original, R)

print "Applying Convolution."
b = convolution(radius, b)

subplot(121)
imshow(original,vmin=0,vmax=1, origin='lower')
subplot(122)
imshow(b,vmin=0,vmax=1, origin='lower')
show()
예제 #2
0
    colormodel = argv[1]
    
# Get the images
images = []
for i in range(0, no_images):
    images.append(imread('amsterdamdb/%s.png' % (str(i))))
    #images.append(imread('TenImages/%s.png' % (str(i))))

# Calculate the number of bins
no_bins = ceil(255/binsize)

# Get the histograms
print "Calculating histograms, please wait..."
histograms = []
for i in images:
    histograms.append(colHist(i, (no_bins, no_bins, no_bins), colormodel))
    print "Calculated histogram."
print "Done calculating the histograms. Now intersecting."
    
# Intersect all the histograms
result = zeros((no_images,no_images))
for i in range(0,no_images):
    for j in range(0,no_images):
        result[i][j] = histogramIntersect(histograms[i], histograms[j])       
print result

# Find the best and worst match
mi = 1
ma = 0
pos_mi = (0, 0)
pos_ma = (0, 0)