2010-05-18 4 views
0

아이폰을 사용하여 RGB 톤 포토를 사용하여 객관적인 척도에 맞춰 아이폰을 사용하는 프로그램을 구입/그들 자신. 누구든지 포인터가있어?아이폰 앱에서 객체의 스킨 톤을 측정하는 방법이 있습니까

+0

입니다 이것은 톤이 빛에 많이 의존 용이하기 때문에, 결과에서 가장 신뢰할 수없는 것이라고하지 않을 수 있습니다. – dbemerlin

+0

@dbemerlin은 제곱 한 것을 말합니다. 모든 사람들은 얼굴 옆에 표준 교정 카드를 보관해야합니다. 뭐하고 있니? 인종 프로파일 링 자동화? <- 농담. –

+0

이 질문은 비슷하게 묻습니다 : http://stackoverflow.com/questions/2720336/how-to-get-skin-tone-color-pixel-in-iphone. –

답변

0

이 문제에 대한 반대 의견은 정확하다고 생각합니다. 정확한 교정을 위해 노력할 것입니다. 그러나 모든 솔루션은

- (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 클래스에서입니다 (...이 경우에있는 UIImageView를) 이미지의 특정 픽셀의 색상을 얻을 수있는에 의존하는 것입니다 다음 (c)

// 3/6/09에 markj 작성. // Copyright 2009 Mark Johnson. 판권 소유.

전체 기사는 여기 http://www.markj.net/iphone-uiimage-pixel-color/

관련 문제