leptonica の pixOtsuAdaptiveThreshold 関数を使用しようとしていますが、ほとんど運がありません。私はそれを正しく行っているかどうかはわかりませんが、UIImage (objective-C) を取得し、pixOtsuAdaptiveThreshold を適用してから UIImage に変換しようとしています。渡したパラメータで pixOtsuAdaptiveThreshold を呼び出すとクラッシュします。
誰が私が間違っているのか教えてもらえますか? 私はこれに2日間苦労しており、気が狂っていると思います。ありがとう!
コード
-(void)leptnoica:(UIImage *)image {
CGImageRef myCGImage = image.CGImage;
CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(myCGImage));
const UInt8 *imageData = CFDataGetBytePtr(data);
PIX *myPix = (PIX *) malloc(sizeof(PIX));
myPix->w = (int)CGImageGetWidth (myCGImage);
myPix->h = (int)CGImageGetHeight (myCGImage);
myPix->d = (int)CGImageGetBitsPerComponent(myCGImage);
myPix->wpl = (CGImageGetBytesPerRow (myCGImage)/4);
// myPix->informat = IFF_TIFF;
myPix->informat= IFF_PNG;
myPix->data = (l_uint32 *) imageData;
myPix->colormap = NULL;
l_int32 one=300;
PIX *pixg;
PIX *pixB;
pixg = (PIX *) malloc(sizeof(PIX));
pixg=pixConvertTo8(myPix, 0);
l_float32 scorefract=0.1f;
pixOtsuAdaptiveThreshold(pixg, one, one, 0, 0, scorefract,NULL,&pixB);