PHPackages                             bediger4000/nudedetectorphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bediger4000/nudedetectorphp

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bediger4000/nudedetectorphp
===========================

Dectect images containing nudity some of the time

v1.1(10y ago)19433PHPPHP ^5.3.3 || ^7.0

Since May 16Pushed 3y ago3 watchersCompare

[ Source](https://github.com/bediger4000/NudeDetectorPHP)[ Packagist](https://packagist.org/packages/bediger4000/nudedetectorphp)[ RSS](/packages/bediger4000-nudedetectorphp/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)DependenciesVersions (2)Used By (0)

NudeDetectorPHP
===============

[](#nudedetectorphp)

PHP implementation of Rigan Ap-Apid's "An Algorithm for Nudity Detection"
-------------------------------------------------------------------------

[](#php-implementation-of-rigan-ap-apids-an-algorithm-for-nudity-detection)

[An Algorithm for Nudity Detection](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.96.9872&rep=rep1&type=pdf)promises an algorithm to determine whether images contain nudity or not. This is a PHP implementation of it.

### Choices

[](#choices)

Ap-Apid's paper doesn't specify the algorithm as tightly as an implementor might wish.

An implementor could decide to use 4-connectivity or 8-connectivity to determine the "connected regions" of skin-colored pixels. I used the [Two Pass](https://en.wikipedia.org/wiki/Connected-component_labeling#Two-pass)algorithm from Wikipedia, and 4-connectivity..

Ap-Apid's algorithm depends on the "three largest regions" of connected skin-colored pixels. Does "largest" just mean greatest pixel count, or do you account for blocks of non-skin-colored pixels inside a region? How do you decide on 3 largest if you have equal sizes (by whatever measure) of more than one region?

The algorithm has you finding "the leftmost, the uppermost, the rightmost, and the lowermost skin pixels of the three largest skin regions. Use these points as the corner points of a bounding polygon."

Which "leftmost"? If the leftmost pixels of a skin-colored region are along the left hand side of an image, many pixels are "leftmost". Do you pick top, bottom or middle leftmost? The same question applies to the other 3 "x most" pixels of each region.

The paper doesn't define "bounding polygon", I took it to be the convex hull that surrounds the twelve points (topmost, leftmost, lowermost and rightmost) of the 3 biggest skin-colored regions. But maybe Ap-Apid means something else, an irregular, possibly concave polygon perhaps.

### Example Use

[](#example-use)

```
#!/usr/bin/env php
