Commit 7be3eb6e by David GEISSBUHLER

python version of tan_specular_highlights removed.

parent 87134851
......@@ -5,8 +5,6 @@ from .galbally_iqm_features import compute_quality_features
from .msu_iqa_features import compute_msu_iqa_features
from ._library import remove_highlights
from . import tan_specular_highlights as tsh
def get_config():
"""
......
......@@ -10,12 +10,10 @@ import bob.ip.base
import bob.ip.color
from . import galbally_iqm_features as iqm
#from . import tan_specular_highlights as tsh
from ._library import remove_highlights
''' Utility functions '''
def matlab_rgb2hsv(rgbImage):
# first normalize the range of values to 0-1
......
......@@ -5,6 +5,8 @@
Created on 28 Jun 2017
@author: dgeissbuhler
Compute average specular histogram of an entire picture folder.
'''
from __future__ import print_function
......@@ -13,21 +15,15 @@ import sys
import argparse
import time
import bob.io.base
import bob.io.image
import bob.io.video
import bob.ip.base
import numpy as np
from bob.ip.qualitymeasure import remove_highlights_orig
from bob.ip.qualitymeasure import remove_highlights
from bob.ip.qualitymeasure import tsh
def main(command_line_parameters=None):
"""Remove the specular component of the input image and write result to
a file.
"""
argParser = argparse.ArgumentParser(
description=__doc__,
......@@ -44,17 +40,15 @@ def main(command_line_parameters=None):
'--output',
dest='output',
default=None,
help='output file.')
help='output text file.')
args = argParser.parse_args(command_line_parameters)
num_hist = 0.0
hist_v0 = np.zeros(256, dtype='uint64')
hist_v1 = np.zeros(256, dtype='uint64')
hist_v2 = np.zeros(256, dtype='uint64')
hist = np.zeros(256, dtype='uint64')
f = open(args.output, 'w')
print('# i v0 v1 v2', file=f)
print('# i bin_value', file=f)
# 1. open input image
print("Opening dir: %s" % args.path)
......@@ -63,35 +57,24 @@ def main(command_line_parameters=None):
# 2. compute
for file in files:
print('processing file: %s' % file)
video = bob.io.video.reader(args.path + file)
frame = video[0]
sfi, diff, residue = tsh.remove_highlights(frame.astype(np.float32), 0.06)
residue[np.where(np.isinf(residue))] = 0
residue[np.where(np.isnan(residue))] = 0
residue[np.where(residue < 0)] = 0
residue[np.where(residue > 255)] = 255
hist_v0 = hist_v0 + bob.ip.base.histogram(residue[0], (0.0, 255.0), 256)
sfi, diff, residue = remove_highlights(frame.astype(np.float32), 0.06)
sfi, diff, residue = remove_highlights_orig(frame.astype(np.float32), 0.06)
residue[np.where(np.isinf(residue))] = 0
residue[np.where(np.isnan(residue))] = 0
residue[np.where(residue < 0)] = 0
residue[np.where(residue > 255)] = 255
hist_v1 = hist_v1 + bob.ip.base.histogram(residue[0], (0.0, 255.0), 256)
sfi, diff, residue = remove_highlights(frame.astype(np.float32), 0.06)
residue[np.where(np.isinf(residue))] = 0
residue[np.where(np.isnan(residue))] = 0
residue[np.where(residue < 0)] = 0
residue[np.where(residue > 255)] = 255
hist_v2 = hist_v2 + bob.ip.base.histogram(residue[0], (0.0, 255.0), 256)
hist = hist + bob.ip.base.histogram(residue[0], (0.0, 255.0), 256)
# 1. save output image
for i in range(256):
print(i, hist_v0[i], hist_v1[i], hist_v2[i], file= f)
print(i, hist[i], file= f)
......
......@@ -15,9 +15,7 @@ import bob.io.base
import bob.io.image
import numpy as np
from bob.ip.qualitymeasure import remove_highlights_orig
from bob.ip.qualitymeasure import remove_highlights
from bob.ip.qualitymeasure import tsh
def main(command_line_parameters=None):
"""Remove the specular component of the input image and write result to
......@@ -55,13 +53,6 @@ def main(command_line_parameters=None):
default=0.5,
help='value of epsilon parameter.')
argParser.add_argument(
'-a',
'--algorithm',
dest='algorithm',
default=0,
help='version of the algoritm used.')
args = argParser.parse_args(command_line_parameters)
if not args.inpImg:
......@@ -76,15 +67,7 @@ def main(command_line_parameters=None):
# 2. compute
print("Extracting diffuse component...")
if int(args.algorithm) == 0:
print('v0')
sfi, diff, residue = tsh.remove_highlights(img.astype(np.float32), float(args.epsilon))
elif int(args.algorithm) == 1:
print('v1')
sfi, diff, residue = remove_highlights_orig(img.astype(np.float32), float(args.epsilon))
else:
print('v2')
sfi, diff, residue = remove_highlights(img.astype(np.float32), float(args.epsilon))
sfi, diff, residue = remove_highlights(img.astype(np.float32), float(args.epsilon))
# 1. save output image
print("Saving output file: %s" % args.outImg)
......
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