Local Laplacian filtering is a computationally intensive algorithm. To speed up processing, locallapfilt
approximates the algorithm by discretizing the intensity range into a number of samples defined by the 'NumIntensityLevels
' parameter. This parameter can be used to balance speed and quality.
Import an RGB image and display it.
Use a sigma
value to process the details and an alpha
value to increase the contrast, effectively enhancing the local contrast of the image.
Using fewer samples increases the execution speed, but can produce visible artifacts, especially in areas of flat contrast. Time the function using only 20 intensity levels.
Now, process the image and display it.
A larger number of samples yields better looking results at the expense of more processing time. Time the function using 100 intensity levels.
Process the image with 100 intensity levels and display it:
Try varying the number of intensity levels on your own images. Try also flattening the contrast (with alpha
> 1). You will see that the optimal number of intensity levels is different for every image and varies with alpha
. By default, locallapfilt
uses a heuristic to balance speed and quality, but it cannot predict the best value for every image.