Ask Your Question

Specular highlights position

asked 2016-12-06 04:38:41 -0500

dmalkr gravatar image

Hello! How to find positions of specular highligts and its size?

I do not need to remove these highlights, just mask it off from image for following processing.

The problem is that I can't detect specularities only by high HSV or RGB value (>255 for example) because of white artefacts on image (labels, subimages etc).

Please, see examples:

First example

And this:

Second example

So, how to position and detect specularities?

edit retag flag offensive close merge delete


LBerger gravatar imageLBerger ( 2016-12-06 06:32:11 -0500 )edit

LBerger, this method didn't work with images where no specularities. When I try this method for first object (book) which image has not specularities, it detect speculars on label (white letters).

Your link to paper seems to be good, I still read it, thank you!

dmalkr gravatar imagedmalkr ( 2016-12-07 05:42:36 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-11-23 05:18:56 -0500

MartinThoma gravatar image

You can use binarization with a threshold on the brightness (L-channel of HSL color space). Then you can apply binarization and opening / closing.

Python sample code

#!/usr/bin/env python

from PIL import Image
import numpy as np
from scipy.misc import imsave
from scipy.ndimage.morphology import binary_closing, binary_opening

def binarize_array(numpy_array, threshold=200):
    Binarize a numpy array.


    numpy_array : numpy array
    threshold : int

    for i in range(len(numpy_array)):
        for j in range(len(numpy_array[0])):
            if numpy_array[i][j] > threshold:
                numpy_array[i][j] = 255
                numpy_array[i][j] = 0
    return numpy_array

im ="14810202126365282.jpg")
im = im.convert('L')
im = np.array(im)
im = binarize_array(im, 200)
im = binary_closing(im, structure=np.ones((10, 10)))
im = binary_opening(im, structure=np.ones((10, 10)))
imsave("out.png", im)

Sample mask for the book

image description

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-12-06 04:38:41 -0500

Seen: 805 times

Last updated: Dec 06 '16