GithubHelp home page GithubHelp logo

bluedokk / shadding-attenuation Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 2.66 MB

Image pre-processing technique to attenuate shadows in samples with non-uniform lighting.

Python 100.00%
python computer-vision alg python3 numpy opencv melanoma-detection

shadding-attenuation's Introduction

Shadding attenuation algorithm ๐Ÿ’ป๐Ÿงฌ

(with DullRazor algorithm)

homepage


Minimum equirements

Programming language: Python
Version language: Python 3.8.8
Libraries: OpenCV 4.5.1, Numpy 1.19.2


The human body is made up of curved surfaces that make the light projected on it not uniform. This circularity creates shadows and adds noise to dermoscopic images, making it difficult to segment the lesion. According to Cavalcanti et al., It is possible to attenuate the shadows present in this type of images by means of a linear regression in 2-D, modeling the variations in lighting and reassigning the values of each pixel.

Taking into account that there are no abrupt changes in the illumination of the image, this variation can be modeled by means of a quadratic function or second degree polynomial. To approximate the coefficients of the polynomial, it is necessary to use the pixels that have more information about the shadows, that is, those found in the corners of the image. Consequently, a set of 20 ร— 20 pixels is extracted from each corner and a matrix ๐‘† is formed containing the union of the four sets (n = 1600 pixels). Then the matrix ๐‘† is used to approximate the coefficients of the quadratic function ๐‘ง (๐‘ฅ, ๐‘ฆ):

๐‘ง(๐‘ฅ,๐‘ฆ)=๐‘1x2+๐‘2y2+๐‘3๐‘ฅ๐‘ฆ+๐‘4๐‘ฅ+๐‘5๐‘ฆ+๐‘6

Where the variables ๐‘ฅ and ๐‘ฆ correspond to the coordinates of each element of ๐‘†.

As the number of pixels is not large, the method of ordinary least squares (OLS) is used to minimize the function ๐‘ง (๐‘ฅ, ๐‘ฆ), and find the parameters ๐‘1 โ‹ฏ ๐‘6. This method is not iterative and therefore has less computational requirements. The expression for OLS, in its matrix form, is given by the following equation:

๐›ฝ=(๐‘‹T๐‘‹)-1๐‘‹T๐‘ฆ

Where ๐›ฝ is the resulting 6 ร— 1 matrix containing the coefficients ๐‘1 โ‹ฏ ๐‘6, ๐‘‹ is an n ร— 6 matrix with the terms for each coordinate (๐‘ฅ, ๐‘ฆ), and ๐‘ฆ is an n ร— 1 matrix containing the intensity values of each pair (๐‘ฅ, ๐‘ฆ).

Once the coefficients have been obtained, ๐‘ง (๐‘ฅ, ๐‘ฆ) is calculated for each pixel of the blue channel of the image, in order to estimate the intensity of local illumination. Finally, the shadows are attenuated by the following expression:

๐‘…(๐‘ฅ,๐‘ฆ)=๐ผ(๐‘ฅ,๐‘ฆ)/๐‘ง(๐‘ฅ,๐‘ฆ)

Where ๐‘… (๐‘ฅ, ๐‘ฆ) is the resulting image, ๐ผ (๐‘ฅ, ๐‘ฆ) the blue layer of the image and ๐‘ง (๐‘ฅ, ๐‘ฆ) the local illumination intensity obtained.

This algorithm use DullRazor technique. To see the algorithm click [here]


SCREENSHOTS

Input image from HAM10000 database.

Input image

Input image

Cropped image

Cropped image

DullRazor

Dullrazor

Blue channel

Blue channel

Attenuator element

Attenuator element

Shadding attenuation on image (Output image)

Output image

Developed by engineer Javier Velasquez (2020)

shadding-attenuation's People

Contributors

bluedokk avatar

Watchers

 avatar

Forkers

pjm358

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.