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 8967875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:20:35+00:00 2026-06-15T17:20:35+00:00

This is the histogram function I’m using today and if I’m not wrong it’s

  • 0

This is the histogram function I’m using today and if I’m not wrong it’s creating an histogram by Gray color.

What i want is another function that will return me 3 histograms of each Bitmap:

The first histogram will be of the Red color of the bitmap the second for the Green color and the last one for the Blue color.

public static long[] GetHistogram(Bitmap b)
        {
            long[] myHistogram = new long[256]; 
            BitmapData bmData = null;

            try
            {
                //Lock it fixed with 32bpp
                bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                int scanline = bmData.Stride;
                System.IntPtr Scan0 = bmData.Scan0;
                unsafe
                {
                    byte* p = (byte*)(void*)Scan0;
                    int nWidth = b.Width;
                    int nHeight = b.Height;
                    for (int y = 0; y < nHeight; y++)
                    {
                        for (int x = 0; x < nWidth; x++)
                        {
                            long Temp = 0;
                            Temp += p[0]; //  p[0] - blue, p[1] - green , p[2]-red
                            Temp += p[1];
                            Temp += p[2];
                            Temp = (int)Temp / 3;
                            myHistogram[Temp]++;
                            //we do not need to use any offset, we always can increment by pixelsize when
                            //locking in 32bppArgb - mode
                            p += 4;
                        }
                    }
                }
                b.UnlockBits(bmData);
            }
            catch
            {
                try
                {
                    b.UnlockBits(bmData);
                }
                catch
                {
                }
            }
            return myHistogram;
       }

How may I do it ?

  • 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-15T17:20:36+00:00Added an answer on June 15, 2026 at 5:20 pm

    In the part where you specify

    Temp += p[0]
    ...
    

    put the three values into separate histograms:

    histB[p[0]]++;
    histG[p[1]]++;
    histR[p[2]]++;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a histogram using (hist) function... after that, I need to save
I've a question regarding Histogram Equalization process using cv::equalizeHist()(a function of OpenCV image processing
I've been trying to implement Reusability on a histogram plotted using d3. I want
I'm drawing a histogram with the standard hist function with this example dataset: v=
I have this member function std::ostream& operator<<(std::ostream &stream) const in Histogram<T> . then in
I have created a histogram with matplotlib using the pyplot.hist() function. I would like
Is there a function in R that fits a curve to a histogram? Let's
I have this sort of C function -- that is being called a zillion
I want to write a function that takes a dataframe, and graphs all the
I am making a function which will make a list which includes a histogram

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.