Commit 7be3eb6e authored by David GEISSBUHLER's avatar David GEISSBUHLER

python version of tan_specular_highlights removed.

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