问题描述:

I am trying to apply a threshold using the leptonica image library with the function

l_int32 pixOtsuAdaptiveThreshold()

I believe I have succesfully used this function but as you can see, it returns an int. I am not sure how to go from here and convert this into a UIImage OR convert the PIX object I passed in into an UIImage? Basically I just want a UIImage back after applying the threshold.

The API for this function can be found here: http://tpgit.github.io/Leptonica/binarize_8c.html#aaef1d6ed54b87144b98c72f675ad7a4c

Does anyone know what I must do to get a UIImage back?

Thanks!

网友答案:

here is another user converting data to image... Reading binary image data from a web service into UIImage

but if you can i would look into brad larsons awesome gpu image filters may be better suited for you https://github.com/BradLarson/GPUImage very easy to use

added answer for adding GPUImage framework: sorry i cant help with the first as for if you would like to continue using the second if you simply need a desired threshold effect you can use gpuimage as a frame work and after setup for adaptive threshold i simply used a switch case for different effects or call init how ever you want and i used a slider to get effects control or select a predetermined value but the code ends up as easy as this

 case GPUIMAGE_ADAPTIVETHRESHOLD:
    {
        self.title = @"Adaptive Threshold";
        self.filterSettingsSlider.hidden = NO;

        [self.filterSettingsSlider setMinimumValue:1.0];
        [self.filterSettingsSlider setMaximumValue:20.0];
        [self.filterSettingsSlider setValue:1.0];


        UIImage *newFilteredImage =  [[[GPUImageAdaptiveThresholdFilter alloc] init] imageByFilteringImage:[self.originalImageView image] ];
        self.myEditedImageView = newFilteredImage;
    }; break;
相关阅读:
Top