+ Reply to Thread
Results 1 to 8 of 8

Thread: Content Based Image Censoring Class

  1. #1
    learning_brain is offline x10 Sophmore learning_brain is an unknown quantity at this point
    Join Date
    Apr 2010
    Location
    UK, Midlands
    Posts
    170

    Content Based Image Censoring Class

    I have been working on this for a while and ideally need some help to tidy it up as it's my first OOP.

    Effectively, I wanted a class that analyses images to check for skin tone percentage. Then return the original image if the percentage is low enough, but return a pixellated image if it is too high together with the option of a link to view the original. Quite a challenge!

    I have now succeeded (tested it and it works), but I'm guessing the code is messy and resource intensive so I'm asking if anyone a) finds this of interest and b) would like to assist in making the code cleaner.

    There are 3 files attached

    1) The class (a lot of commented out stuff here that I used to determine what a skintone is)
    2) A dynamic pixellated image renderer (same directory)
    4) The test html page

    The class call has a number of variables to control the output.

    First is the source url
    Second.. if "Message" is entered rather than "", a warning message will be output.
    Third.. if "Link" is entered rather than "", it will provide the link to view the original.
    Fourth.. adjust the sensitivity. In this case, the percentage skintone threshold is 15%. If the image contains more than 15% skintones, it will return a pixellated image. The higher the percentage, the more skintones need to be present before pixellation.

    The class will return the complete image so no need for <img src="anything"/> etc...

    PHP Code:
    $analysedImage = new ImageAnalysis();
    $analysedImage->doAnalysis("thefullurl","Message","Link","15"); 
    It doesn't seem to return pixellated images for all urls... for some reason.

    This will be extremely useful for my search engine, but may be helpful to others as well.

    Any ideas?
    Attached Files
    Last edited by learning_brain; 01-31-2011 at 05:16 PM.

  2. #2
    learning_brain is offline x10 Sophmore learning_brain is an unknown quantity at this point
    Join Date
    Apr 2010
    Location
    UK, Midlands
    Posts
    170

    Re: Content Based Image Censoring Class

    Sorry for the double post, but this has undergone some serious mods.

    Class now returns a simple image URL (Original or pixellated), together with pass/fail variable.

    the class entry variables are now source URL, sensitivity, pixellation amount.

    Example can be seen working at http://www.qualityimagesearch.com/test.php

    The major problem is the processing time. It's highly effective, but way too slow. I may have to dump this project.

    If anyone is interested in seeing the scripts, let me know.
    Last edited by learning_brain; 02-02-2011 at 04:45 PM.

  3. #3
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Content Based Image Censoring Class

    Is this evaluating the image on load? If so, can it not be done when you are finding the images rather than when loading?
    Also, if you plan to continue with this you'll likely want to implement an option to toggle it on or off, as it seems it gives quite a lot of false-positives that users may wish to avoid.

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Content Based Image Censoring Class

    The concept is flawed to begin with.

    Define "skin tone".

    What if the model is wearing nothing but green body paint?

    What if she is wearing a green leotard with x-rated holes cut in it?

    A head shot can be 90% skin tone and not 'pornographic'
    Nothing is always absolutely so.

  5. #5
    learning_brain is offline x10 Sophmore learning_brain is an unknown quantity at this point
    Join Date
    Apr 2010
    Location
    UK, Midlands
    Posts
    170

    Re: Content Based Image Censoring Class

    Quote Originally Posted by lemon-tree View Post
    Is this evaluating the image on load? If so, can it not be done when you are finding the images rather than when loading?
    Also, if you plan to continue with this you'll likely want to implement an option to toggle it on or off, as it seems it gives quite a lot of false-positives that users may wish to avoid.
    This is evaluating in real-time: more reliable, but much slower - probably unacceptably slow. I like your idea though. It would be simple enough to store a suitable/risk variable in the database.

    The toggle system I have already though of. Adding a preferences page, with a server variable (or a cookie) would do this nicely and I could add a class variable that stops the class running.

    Quote Originally Posted by descalzo View Post
    The concept is flawed to begin with.

    Define "skin tone".

    What if the model is wearing nothing but green body paint?

    What if she is wearing a green leotard with x-rated holes cut in it?

    A head shot can be 90% skin tone and not 'pornographic'
    Yeah - I had a nasty feeling someone would say this...

    My second attempt (this is the 3rd) was far more complex, storing a range of rgb values as a serialised string in the database (much like a cbir system), which could then be compared using an existing stored set of example images and returning a % similarity. I assumed that this would provide a set of recognised patterns that could be compared against rather than a simple "skin tone %", but after much testing, it wasn't working how I wanted it to and I reverted backwards.

    You are right - it is severely flawed, although it could be perceived as an improvement over existing image search engines.

    The best method would be to recognise certain patterns within the image, but I do not have any idea how to even approach this effectively yet.

    Thanks for the feedback.
    Last edited by learning_brain; 02-03-2011 at 06:47 AM.

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Content Based Image Censoring Class

    Quote Originally Posted by learning_brain View Post
    The best method would be to recognise certain patterns within the image, but I do not have any idea how to even approach this effectively yet.
    There was a time when neural networks were all the rage for this sort of problem, though I don't know as though they're as highly thought of these days.

    You could explore image similarity algorithms. Sample images of interest (pornographic, artistic nudes, beach-goers &c). See how similar they are to each other. Record the metrics of various sample images, then compare new images to those metrics.

    In the end, any non-semantic comparison is destined to fail in a noticeable number of cases. Of course, if you can get a computer to perform semantic image comparison, you'll win a Turing award.

    You could base censoring not only on the image itself but side-channel information, such as the URL, the text of the page where you found the image (especially the text near the image) and the page that linked to the image page.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  7. #7
    learning_brain is offline x10 Sophmore learning_brain is an unknown quantity at this point
    Join Date
    Apr 2010
    Location
    UK, Midlands
    Posts
    170

    Re: Content Based Image Censoring Class

    Damn - image similarity was how I was approaching it previously!!!

    I was just getting weird results - maybe I didn't have enough comparison data.

    I think this needs a major re-think....

    Case closed for the time being.

  8. #8
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Content Based Image Censoring Class

    Try training some neural networks. As long as you've got a large sample that you've classified, they have a decent possibility of working. The main problem will probably be that the size of the network is O(width*height) of the images, with O((width*height)**2) initial connections.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Content Based Image Analysis
    By learning_brain in forum Earning Money
    Replies: 0
    Last Post: 11-05-2010, 06:06 PM
  2. Content based publisher : advertising on your site
    By gptsven in forum Earning Money
    Replies: 3
    Last Post: 08-25-2010, 09:59 AM
  3. Video tutorial : content based advertising
    By gptsven in forum Tutorials
    Replies: 2
    Last Post: 04-18-2010, 04:35 AM
  4. CLASS or ID?
    By cursedpsp in forum Programming Help
    Replies: 5
    Last Post: 06-06-2008, 06:37 AM
  5. Div Class / Div ID ??
    By mikel2k3 in forum Scripts & 3rd Party Apps
    Replies: 3
    Last Post: 10-14-2007, 10:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers