bir çok kolay bir yaklaşım CGImageRef kod çözme dizisi kullanmak, ama bu sadece bir aralık haritalama (bir gamma, vs.) için yardımcı olabilir
beyaz nokta 0.0 arasında bir kayan nokta
const CGFloat decode[6] = {blackPoint,whitePoint,blackPoint,whitePoint,blackPoint,whitePoint};
decodedImage = CGImageCreate(CGImageGetWidth(origImage),
CGImageGetHeight(origImage),
CGImageGetBitsPerComponent(origImage),
CGImageGetBitsPerPixel(origImage),
CGImageGetBytesPerRow(origImage),
CGImageGetColorSpace(origImage),
CGImageGetBitmapInfo(origImage),
CGImageGetDataProvider(origImage),
decode,
YES,
CGImageGetRenderingIntent(origImage)
);
1.0, hangi parlaklığın çıktıdaki saf beyaza eşleneceğini belirler ve blackPoint aynı zamanda hangi parlaklığın saf siyahla eşlendiğini belirleyen bir yüzdür.
Kod çözme dizisinin öğeleri, renk uzayının bileşenlerine karşılık gelir, bu nedenle bu kod yalnızca RBG görüntüleri için çalışır. Basit bir renk düzeltmesi oluşturmak için bileşenleri farklı beyaz ve siyah değerlere ayarlayabilirsiniz.
Sen Beyaznokta ve (renk düzeltme w/o) Aşağıdaki fonksiyonu ile blackPoint hesaplayabilirsiniz: Sen CImg kütüphane deneyebilirsiniz
void CalculateAutocorretionValues(CGImageRef image, CGFloat *whitePoint, CGFloat *blackPoint) {
UInt8* imageData = malloc(100 * 100 * 4);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(imageData, 100, 100, 8, 4 * 100, colorSpace, kCGImageAlphaNoneSkipLast);
CGColorSpaceRelease(colorSpace);
CGContextDrawImage(ctx, CGRectMake(0, 0, 100, 100), image);
int histogramm[256];
bzero(histogramm, 256 * sizeof(int));
for (int i = 0; i < 100 * 100 * 4; i += 4) {
UInt8 value = (imageData[i] + imageData[i+1] + imageData[i+2])/3;
histogramm[value]++;
}
CGContextRelease(ctx);
free(imageData);
int black = 0;
int counter = 0;
// count up to 200 (2%) values from the black side of the histogramm to find the black point
while ((counter < 200) && (black < 256)) {
counter += histogramm[black];
black ++;
}
int white = 255;
counter = 0;
// count up to 200 (2%) values from the white side of the histogramm to find the white point
while ((counter < 200) && (white > 0)) {
counter += histogramm[white];
white --;
}
*blackPoint = 0.0 - (black/256.0);
*whitePoint = 1.0 + ((255-white)/256.0);
}
Uhmm, otomatik düzeyleri nedir? – vodkhang
"Otomatik Düzeyler", Photoshop gibi görüntü düzenleme programlarının çoğunda görüntünün ton aralığını geliştiren bir seçenektir. –
Bu umut verici görünüyor: http://code.google.com/p/simple-iphone-image-processing/ –