Commit 7049ebba authored by Taddeüs Kroes's avatar Taddeüs Kroes

ImProc ass3: Fuxed RGB color issue (?).

parent 0374d175
...@@ -11,15 +11,15 @@ def domainIterator(image): ...@@ -11,15 +11,15 @@ def domainIterator(image):
def colHist(image, bins, model): def colHist(image, bins, model):
h = zeros(tuple(bins)) h = zeros(tuple(bins))
image *= list(bins) use = image.astype(float) * bins
if model == 'rgb': if model == 'rgb':
image /= 255. use /= 255
elif model == 'rgba': elif model == 'hsv':
pass pass
for p in domainIterator(image): for p in domainIterator(image):
h[col2bin(image[p])] += 1 h[col2bin(use[p])] += 1
return h return h
...@@ -28,6 +28,7 @@ def histogramIntersect(h1, h2): ...@@ -28,6 +28,7 @@ def histogramIntersect(h1, h2):
raise ValueError('Shape mismatch between h1 and h2.') raise ValueError('Shape mismatch between h1 and h2.')
match = 0 match = 0
#print h1, h2
for r in xrange(h1.shape[0]): for r in xrange(h1.shape[0]):
for g in xrange(h1.shape[1]): for g in xrange(h1.shape[1]):
...@@ -39,12 +40,12 @@ def histogramIntersect(h1, h2): ...@@ -39,12 +40,12 @@ def histogramIntersect(h1, h2):
# Create table of intersections # Create table of intersections
if __name__ == '__main__': if __name__ == '__main__':
bins = [8] * 3 bins = [8] * 3
db = map(lambda x: imread('database/%d.jpg' % x), range(1, 3)) db = map(lambda x: imread('database/%d.jpg' % x), range(1, 21))
table = zeros((len(db), len(db))) table = zeros((len(db), len(db)))
for i, im in enumerate(db): for i, im in enumerate(db):
for j in xrange(i + 1, len(db)): for j in xrange(i + 1, len(db)):
print 'comparing', i, j #print 'comparing', i, j
table[i, j] = histogramIntersect(colHist(im, bins, 'rgb'), table[i, j] = histogramIntersect(colHist(im, bins, 'rgb'),
colHist(db[j], bins, 'rgb')) colHist(db[j], bins, 'rgb'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment