Berechnen Sie das Histogramm eines Bildes mit vImageHistogramCalculation
Ich versuche, das Histogramm eines Bildes mit vImage's @ zu berechnevImageHistogramCalculation_ARGBFFFF
, aber ich bekomme einvImage_Error
vom TypkvImageNullPointerArgument
(Fehlercode a -21772).
Hier ist mein Code:
- (void)histogramForImage:(UIImage *)image {
//setup inBuffer
vImage_Buffer inBuffer;
//Get CGImage from UIImage
CGImageRef img = image.CGImage;
//create vImage_Buffer with data from CGImageRef
CGDataProviderRef inProvider = CGImageGetDataProvider(img);
CFDataRef inBitmapData = CGDataProviderCopyData(inProvider);
//The next three lines set up the inBuffer object
inBuffer.width = CGImageGetWidth(img);
inBuffer.height = CGImageGetHeight(img);
inBuffer.rowBytes = CGImageGetBytesPerRow(img);
//This sets the pointer to the data for the inBuffer object
inBuffer.data = (void*)CFDataGetBytePtr(inBitmapData);
//Prepare the parameters to pass to vImageHistogramCalculation_ARGBFFFF
vImagePixelCount *histogram[4] = {0};
unsigned int histogram_entries = 4;
Pixel_F minVal = 0;
Pixel_F maxVal = 255;
vImage_Flags flags = kvImageNoFlags;
vImage_Error error = vImageHistogramCalculation_ARGBFFFF(&inBuffer,
histogram,
histogram_entries,
minVal,
maxVal,
flags);
if (error) {
NSLog(@"error %ld", error);
}
//clean up
CGDataProviderRelease(inProvider);
}
ch vermute, es hat etwas mit meinem @ zu thistogram
-Parameter, der laut Dokumentation "ein Zeiger auf ein Array von vier Histogrammen" sein soll. Erkläre ich es richtig?
Vielen Dank