Ask Your Question
0

Specular highlights position

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

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

Comments

2
LBerger gravatar imageLBerger ( 2016-12-06 06:32:11 -0600 )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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

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

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.

    Source: https://stackoverflow.com/a/37497975/562769

    Parameters
    ----------
    numpy_array : numpy array
    threshold : int

    Returns
    -------
    numpy_array
    """
    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
            else:
                numpy_array[i][j] = 0
    return numpy_array

im = Image.open("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

Question Tools

1 follower

Stats

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

Seen: 1,963 times

Last updated: Dec 06 '16