2010-05-18 2 views
0

Im пытается найти способ программирования/покупки приложения, чтобы использовать iphone для определения тона кожи кого-то на объективной шкале с использованием RGB с фото, которое они принимают самих себя. У кого-нибудь есть указатели?Есть ли способ измерить тон кожи объекта из приложения iphone

+0

Это может быть не так легко, так как тон зависит много на свете, то результаты будут ненадежными в лучшем случае. – dbemerlin

+0

что @dbemerlin говорит в квадрате. каждый должен был бы держать стандартную калибровочную карточку рядом с их лицом. Что делаешь? автоматизация расового профилирования? <- шутка. –

+0

Этот вопрос задает нечто подобное: http://stackoverflow.com/questions/2720336/how-to-get-skin-tone-color-pixel-in-iphone, хотя и не очень четко. –

ответ

0

Я думаю, что возражения против этого правильны - это будет довольно тяжелая работа по его калибровке. Тем не менее, любое решение будет опираться на возможность получить цвет определенного пикселя в изображении (в данном случае UIImageView ...)

- (UIColor*) getPixelColorAtLocation:(CGPoint)point {

UIColor* color = nil; 
CGImageRef inImage = self.image.CGImage; 
// Create off screen bitmap context to draw the image into. Format ARGB is 4 bytes for each pixel: Alpa, Red, Green, Blue 
CGContextRef cgctx = [self createARGBBitmapContextFromImage:inImage]; 
if (cgctx == NULL) { return nil; /* error */ } 

size_t w = CGImageGetWidth(inImage); 
size_t h = CGImageGetHeight(inImage); 
CGRect rect = {{0,0},{w,h}}; 

// Draw the image to the bitmap context. Once we draw, the memory 
// allocated for the context for rendering will then contain the 
// raw image data in the specified color space. 
CGContextDrawImage(cgctx, rect, inImage); 

// Now we can get a pointer to the image data associated with the bitmap 
// context. 
unsigned char* data = CGBitmapContextGetData (cgctx); 
if (data != NULL) { 
    //offset locates the pixel in the data from x,y. 
    //4 for 4 bytes of data per pixel, w is width of one row of data. 
    int offset = 4*((w*round(point.y))+round(point.x)); 
    int alpha = data[offset]; 
    int red = data[offset+1]; 
    int green = data[offset+2]; 
    int blue = data[offset+3]; 
    NSLog(@"offset: %i colors: RGB A %i %i %i %i",offset,red,green,blue,alpha); 
    color = [UIColor colorWithRed:(red/255.0f) green:(green/255.0f) blue:(blue/255.0f) alpha:(alpha/255.0f)]; 
} 

// When finished, release the context 
CGContextRelease(cgctx); 
// Free image data memory for the context 
if (data) { free(data); } 

return color; 

}

Этот код из класса colourPicker, который несет (c)

// Создано markj в 06.03.09. // Авторское право 2009 Марк Джонсон. Все права защищены.

Полный текст статьи здесь http://www.markj.net/iphone-uiimage-pixel-color/

 Смежные вопросы

  • Нет связанных вопросов^_^