How to get skin tone color pixel in iPhone?
<p>Hi
In my application I m using following way to get red pixel in a image </p>

<pre><code>//
//  PixelsAccessAppDelegate.h
//  PixelsAccess
//
//  Created by Fortune1 on 14/04/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import &lt;UIKit/UIKit.h&gt;
@class clsPixelAccess;
NSUInteger numberOfRedPixels;
NSUInteger numberOfRedPixels1;
NSUInteger numberOfRedPixels2;
NSUInteger numberOfRedPixels3;
NSUInteger numberOfRedPixels4;
NSUInteger numberOfRedPixels5;
NSUInteger numberOfRedPixels6;
NSUInteger numberOfRedPixels7;
NSUInteger numberOfRedPixels8;
NSUInteger numberOfRedPixels9;
NSUInteger numberOfRedPixels10;
NSUInteger numberOfRedPixels11;
NSUInteger numberOfRedPixels12;
NSUInteger numberOfRedPixels13;
NSUInteger numberOfRedPixels14;
NSUInteger numberOfRedPixels15;
NSUInteger numberOfRedPixels16;
NSUInteger numberOfRedPixels17;
NSUInteger numberOfRedPixels18;
NSUInteger numberOfRedPixels19;
NSUInteger numberOfRedPixels20;
NSUInteger numberOfRedPixels21;
NSUInteger numberOfRedPixels22;
NSUInteger numberOfRedPixels23;
NSUInteger numberOfRedPixels24;
NSUInteger numberOfRedPixels25;
NSUInteger numberOfRedPixels26;
NSUInteger numberOfRedPixels27;
NSUInteger numberOfRedPixels28;
NSUInteger numberOfRedPixels29;
NSUInteger numberOfRedPixels30;
NSUInteger numberOfRedPixels31;

@interface PixelsAccessAppDelegate : NSObject &lt;UIApplicationDelegate&gt; {
    UIWindow *window;
    clsPixelAccess *obj;

}

@property (nonatomic, retain) IBOutlet UIWindow *window;
-(IBAction)processImage:(id)sender;

@end

////////////////////
//
//  PixelsAccessAppDelegate.m
//  PixelsAccess
//
//  Created by Fortune1 on 14/04/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "PixelsAccessAppDelegate.h"
#import "clsPixelAccess.h"

@implementation PixelsAccessAppDelegate

@synthesize window;

- (IBAction)processImage:(id)sender
{  
    NSUInteger retVal;
    obj = [[clsPixelAccess alloc] init];

    NSInteger imageSend =[obj processImage1:[UIImage imageNamed:@"s.jpg"]];
    NSInteger iamgeCall =[obj getPixelData:retVal];
    NSUInteger *numberOfRedPixels = retVal; 
    //lblPixelCount.text = [NSString stringWithFormat: @"There are %d red pixels in the image", numberOfRedPixels];

}

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after application launch
    [window makeKeyAndVisible];
}


- (void)dealloc {
    [window release];
    [super dealloc];
}


@end
///////////////

//
//  clsPixelsAccess.h
//  PixelsAccess
//
//  Created by Fortune1 on 14/04/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import &lt;Foundation/Foundation.h&gt;


@interface clsPixelAccess : NSObject {

}
-(NSInteger) processImage1: (UIImage*) image;
-(NSInteger)getPixelData:(NSUInteger *)pixelCount;
@end
/////////


//
//  clsPixelsAccess.m
//  PixelsAccess
//
//  Created by Fortune1 on 14/04/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "clsPixelAccess.h"
#import "PixelsAccessAppDelegate.h"

@implementation clsPixelAccess

struct pixel
{
    //unsigned char r, g, b,a;
    Byte r, g, b, a;
    int count;
};


-(NSInteger)getPixelData:(NSUInteger *)pixelCount
{
    *pixelCount =numberOfRedPixels;
    return 1;

}
// Process the image and return the number of pure red pixels in it.

- (NSInteger) processImage1: (UIImage*) image
{

    // Allocate a buffer big enough to hold all the pixels

    struct pixel* pixels = (struct pixel*) calloc(1, image.size.width * image.size.height * sizeof(struct pixel));
    if (pixels != nil)
    {
        // Create a new bitmap
        CGContextRef context = CGBitmapContextCreate(
                                                     (void*) pixels,
                                                     image.size.width,
                                                     image.size.height,
                                                     8,
                                                     image.size.width * 4,
                                                     CGImageGetColorSpace(image.CGImage),
                                                     kCGImageAlphaPremultipliedLast
                                                     );
        //NSLog(@"1=%d, 2=%d, 3=%d", CGImageGetBitsPerComponent(image), CGImageGetBitsPerPixel(image),CGImageGetBytesPerRow(image));
        if (context != NULL)
        {
            // Draw the image in the bitmap
            CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, image.size.width, image.size.height), image.CGImage);
            NSUInteger numberOfPixels = image.size.width * image.size.height;
            NSMutableArray *numberOfPixelsArray = [[[NSMutableArray alloc] initWithCapacity:numberOfPixelsArray] autorelease];
            NSLog( @"Pixel data %d", numberOfPixelsArray);

            /*  
             NSMatrix      *newMatrix = [[NSMatrix alloc] 
             initWithFrame:NSMakeRect(138.0f, 85.0f, 0.0f, 0.0f)
             mode:NSRadioModeMatrix
             prototype:prototypeButtonCell 
             numberOfRows: 

             numberOfColumns:];
             */ 
            while (numberOfPixels &gt; 0)
            {
                if (pixels-&gt;r &gt; 0 &amp;&amp; pixels-&gt;r &lt;= 7)
                {
                    numberOfRedPixels++;
                }
                NSLog( @"Red pixel data %d",numberOfRedPixels);

                if (pixels-&gt;r &gt;= 8 &amp;&amp; pixels-&gt;r &lt;= 15)
                {
                    numberOfRedPixels1++;
                }

                NSLog( @"Red pixel data1 %d",numberOfRedPixels1);

                if (pixels-&gt;r &gt;= 16 &amp;&amp; pixels-&gt;r &lt;=23 )
                {
                    numberOfRedPixels2++;
                }
                NSLog( @"Red pixel data2 %d",numberOfRedPixels2);

                if (pixels-&gt;r &gt;= 24 &amp;&amp; pixels-&gt;r &lt;=31 )
                {
                    numberOfRedPixels3++;
                }
                NSLog( @"Red pixel data3 %d",numberOfRedPixels3);

                if (pixels-&gt;r &gt;= 32 &amp;&amp; pixels-&gt;r &lt;= 39)
                {
                    numberOfRedPixels4++;
                }
                NSLog( @"Red pixel data4 %d",numberOfRedPixels4);

                if (pixels-&gt;r &gt;= 40 &amp;&amp; pixels-&gt;r &lt;= 47)
                {
                    numberOfRedPixels5++;
                }
                NSLog( @"Red pixel data5 %d",numberOfRedPixels5);
                if (pixels-&gt;r &gt;= 48 &amp;&amp; pixels-&gt;r &lt;= 55)
                {
                    numberOfRedPixels6++;
                }
                NSLog( @"Red pixel data6 %d",numberOfRedPixels6);

                if(pixels-&gt;r &gt;= 56 &amp;&amp; pixels-&gt;r &lt;= 63)
                {
                    numberOfRedPixels7++;
                }
                NSLog( @"Red pixel data7 %d",numberOfRedPixels7);

                if (pixels-&gt;r &gt;= 64 &amp;&amp; pixels-&gt;r &lt;= 71)
                {
                    numberOfRedPixels8++;
                }
                NSLog( @"Red pixel data8 %d",numberOfRedPixels8);

                if (pixels-&gt;r &gt;=  72 &amp;&amp; pixels-&gt;r &lt;= 79)
                {
                    numberOfRedPixels9++;
                }
                NSLog( @"Red pixel data9 %d",numberOfRedPixels9);

                if (pixels-&gt;r &gt;= 80 &amp;&amp; pixels-&gt;r &lt;= 87)
                {
                    numberOfRedPixels10++;
                }
                NSLog( @"Red pixel data10 %d",numberOfRedPixels10);

                if (pixels-&gt;r &gt;= 88 &amp;&amp; pixels-&gt;r &lt;= 95)
                {
                    numberOfRedPixels11++;
                }
                NSLog( @"Red pixel data11 %d",numberOfRedPixels11);

                if (pixels-&gt;r &gt;= 96 &amp;&amp; pixels-&gt;r &lt;= 103)
                {
                    numberOfRedPixels12++;
                }
                NSLog( @"Red pixel data12 %d",numberOfRedPixels12);

                if (pixels-&gt;r &gt;= 104  &amp;&amp; pixels-&gt;r &lt;= 111)
                {
                    numberOfRedPixels13++;
                }
                NSLog( @"Red pixel data13 %d",numberOfRedPixels13);

                if (pixels-&gt;r &gt;= 112 &amp;&amp; pixels-&gt;r &lt;= 119)
                {
                    numberOfRedPixels14++;
                }
                NSLog( @"Red pixel data14 %d",numberOfRedPixels14);

                if (pixels-&gt;r &gt;= 120 &amp;&amp; pixels-&gt;r &lt;= 127)
                {
                    numberOfRedPixels15++;
                }
                NSLog( @"Red pixel data15 %d",numberOfRedPixels15);
                if (pixels-&gt;r &gt; 128 &amp;&amp; pixels-&gt;r &lt;= 135)
                {
                    numberOfRedPixels16++;
                }
                NSLog( @"Red pixel data16 %d",numberOfRedPixels16);

                if (pixels-&gt;r &gt;= 136 &amp;&amp; pixels-&gt;r &lt;= 143)
                {
                    numberOfRedPixels17++;
                }

                NSLog( @"Red pixel data17 %d",numberOfRedPixels17);

                if (pixels-&gt;r &gt;= 144 &amp;&amp; pixels-&gt;r &lt;=151)
                {
                    numberOfRedPixels18++;
                }
                NSLog( @"Red pixel data18 %d",numberOfRedPixels18);

                if (pixels-&gt;r &gt;= 152 &amp;&amp; pixels-&gt;r &lt;=159 )
                {
                    numberOfRedPixels19++;
                }
                NSLog( @"Red pixel data19 %d",numberOfRedPixels19);

                if (pixels-&gt;r &gt;= 160 &amp;&amp; pixels-&gt;r &lt;= 167)
                {
                    numberOfRedPixels20++;
                }
                NSLog( @"Red pixel data20 %d",numberOfRedPixels20);

                if (pixels-&gt;r &gt;= 168 &amp;&amp; pixels-&gt;r &lt;= 175)
                {
                    numberOfRedPixels21++;
                }
                NSLog( @"Red pixel data21 %d",numberOfRedPixels21);
                if (pixels-&gt;r &gt;= 176 &amp;&amp; pixels-&gt;r &lt;= 199)
                {
                    numberOfRedPixels22++;
                }
                NSLog( @"Red pixel data22 %d",numberOfRedPixels22);

                if(pixels-&gt;r &gt;= 184 &amp;&amp; pixels-&gt;r &lt;= 191)
                {
                    numberOfRedPixels23++;
                }
                NSLog( @"Red pixel data23 %d",numberOfRedPixels23);

                if (pixels-&gt;r &gt;= 192 &amp;&amp; pixels-&gt;r &lt;= 199)
                {
                    numberOfRedPixels24++;
                }
                NSLog( @"Red pixel data24 %d",numberOfRedPixels24);

                if (pixels-&gt;r &gt;= 200 &amp;&amp; pixels-&gt;r &lt;= 207)
                {
                    numberOfRedPixels25++;
                }
                NSLog( @"Red pixel data25 %d",numberOfRedPixels25);

                if (pixels-&gt;r &gt;= 208 &amp;&amp; pixels-&gt;r &lt;= 215)
                {
                    numberOfRedPixels26++;
                }
                NSLog( @"Red pixel data26 %d",numberOfRedPixels26);

                if (pixels-&gt;r &gt;= 216 &amp;&amp; pixels-&gt;r &lt;= 223)
                {
                    numberOfRedPixels27++;
                }
                NSLog( @"Red pixel data27 %d",numberOfRedPixels27);

                if (pixels-&gt;r &gt;= 224 &amp;&amp; pixels-&gt;r &lt;= 231)
                {
                    numberOfRedPixels28++;
                }
                NSLog( @"Red pixel data28 %d",numberOfRedPixels28);

                if (pixels-&gt;r &gt;= 232  &amp;&amp; pixels-&gt;r &lt;= 239)
                {
                    numberOfRedPixels29++;
                }
                NSLog( @"Red pixel data29 %d",numberOfRedPixels29);

                if (pixels-&gt;r &gt;= 240 &amp;&amp; pixels-&gt;r &lt;= 247)
                {
                    numberOfRedPixels30++;
                }
                NSLog( @"Red pixel data30 %d",numberOfRedPixels30);

                if (pixels-&gt;r &gt;= 248)
                {
                    numberOfRedPixels31++;
                }
                NSLog( @"Red pixel data31 %d",numberOfRedPixels31);
                pixels++;

                numberOfPixels--;
            }

            CGContextRelease(context);
        }

        free(pixels);
    }

    return 1;
}           

@end
</code></pre>

<p>My problem is I want skin Tone Pixel how it could be possible</p>

<p>Please help me out.</p>

<p>Thanks in Advance</p>
