Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:27:54+00:00 2026-06-17T11:27:54+00:00

Working on https://github.com/luisespinoza/LEColorPicker project, I am trying to generate an histogram UIImage from an

  • 0

Working on https://github.com/luisespinoza/LEColorPicker project, I am trying to generate an histogram UIImage from an arbitrary input UIImage using the project GPUImage (https://github.com/BradLarson/GPUImage).

The current code that I’m using is the following:

- (NSDictionary*)dictionaryWithColorsPickedFromImage:(UIImage *)image
{
    GPUImageFilter *filter = [[GPUImageHistogramFilter alloc] initWithHistogramType:kGPUImageHistogramRGB];

    UIImage *filteredImage = [filter imageByFilteringImage:image];

    [UIImagePNGRepresentation(filteredImage) writeToFile:@"/Users/Luis/histogram.png" atomically:YES];

    return nil;
}

The problem is that histogram.png is resulting in just a black line for every input image.

So, how will be the correct code to generate an histogram UIImage using iOS GPUImage?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:27:55+00:00Added an answer on June 17, 2026 at 11:27 am

    You can look at the FilterShowcase example to see how this is supposed to work in practice.

    The GPUImageHistogramFilter takes in an image and outputs a 256×3 image that encodes the histogram (it’s 3 pixels tall because a 1 pixel height isn’t allowed in framebuffer construction). The R, G, and B values are stored in their respective color channels within a central 1-pixel-tall stripe at the center of that image.

    To visualize this, you’ll need to use a GPUImageHistogramGenerator, and feed the GPUImageHistogramFilter’s output into that. The GPUImageHistogramGenerator creates a visual representation of the histogram input as an image. You do need to use -forceProcessingAtSize: to set the size for the GPUImageHistogramGenerator’s output image, because it doesn’t have a set size by default.

    One other caution is that you’ll need to have a dummy filter of some kind between your input image and the GPUImageHistogramFilter. GPUImageHistogramFilter currently relies on glReadPixels() and that only works for rendered content, not directly uploaded images or video frames.

    The code used in the FilterShowcase for this is as follows:

            filter = [[GPUImageHistogramFilter alloc] initWithHistogramType:kGPUImageHistogramRGB];
    
            GPUImageGammaFilter *gammaFilter = [[GPUImageGammaFilter alloc] init];
            [videoCamera addTarget:gammaFilter];
            [gammaFilter addTarget:filter];
    
            GPUImageHistogramGenerator *histogramGraph = [[GPUImageHistogramGenerator alloc] init];
    
            [histogramGraph forceProcessingAtSize:CGSizeMake(256.0, 330.0)];
            [filter addTarget:histogramGraph];
    
            GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
            blendFilter.mix = 0.75;            
            [blendFilter forceProcessingAtSize:CGSizeMake(256.0, 330.0)];
    
            [videoCamera addTarget:blendFilter];
            [histogramGraph addTarget:blendFilter];
    
            [blendFilter addTarget:filterView];
    

    This overlays the generated histogram visualization on top of the incoming camera video.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use library from https://github.com/XamlAnimatedGif/WpfAnimatedGif/ to solve my animation gif using
I'm trying to use the Ankusa (https://github.com/livingsocial/ankusa) gem in a ruby project I'm working
I am using Linkedin iphone SDK https://github.com/ResultsDirect/LinkedIn-iPhone It was working fine But from this
I am using sample from https://github.com/liveservices/LiveSDK but it isn't working. I managed to run
Here is my group's project: https://github.com/stuycs-ml7-projects/YAN-SHAN-PHAN-WU We're working on app (a website) that can
I'm working to the following little project: https://github.com/AndreaCrotti/project-organizer Which in short aims to manage
I am using following for capturing signature on my application https://github.com/Cheesebaron/MonoDroid.CaptureSignature Its working fine
I'm using Cheerio (https://github.com/MatthewMueller/cheerio) to scrape websites and get images for a project I'm
I am using jQuery Splitter plugin from https://github.com/jcubic/jquery.splitter . Splitter works fine. I need
Tinymce stops working if on the same page I use the selectmenu from https://github.com/fnagel/jquery-ui

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.