Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
18 years ago

How to implement an histogram in a FPGA device??

I need to implement an histogram in a FPGA for 2D image frames.

Any suggestion or reference design???

Thanks in advance.

8 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Take a RAM block full of zeros

    As each pixel comes in, use it as an *address* into the RAM block, take the data, increment it and write it back in.

    If your FPGA clock is less than 2x the pixel clock, you need to be a bit cleverer to account for the RAM read latency...

    Cheers,

    Martin
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Martin,

    Thanks a lot for giving to me such a good trick, I've got implemented it in dspbuilder and i'm testing it using Simulink. At this point I've have the histogram values within a double port RAM, but i have some doubts about how get the statistical mode.

    I've attached a part of my design for more information.

    best regards!!!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    For the mode, don't you just find the histogram bin with the highest value in?

    At the end of the frame, go through each address in the histogram with a counter and latch the address and data values if the data is bigger than your previous "biggest value".

    Cheers

    Martin
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Latch might not have been the best choice of terminology on my part - what I meant was a set of flipflops which are enabled only when you want to store data in them (ie when you have a new "biggest value"). I didn't mean a latch in the old 7475 latch sense - They're usually a bad idea in FPGA-land!

    Cheers,

    Martin
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    OK Martin I know what you wanted to mean, I'm trying to do using two 8 bit d-type flip-flop updating the new maximun value of the frequency and the value associated.

    Your explanation was enough for me. Are you currently working with FPGA's??? or just in image processing?

    regards
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    i've got a project to write a VHDL program for Histogram computation of a 16x16 grey image...... can you please guide me on how to do it?? i'm new to vhdl and fpga's......

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    i've got a project to write a VHDL program for Histogram computation of a 16x16 grey image...... can you please guide me on how to do it?? i'm new to vhdl and fpga's......

    --- Quote End ---

    This thread already gives you a few good hints.