Image Processing... need help

Discussion in 'VHDL' started by vikramtheone, Jun 10, 2009.

  1. vikramtheone

    vikramtheone

    Joined:
    Jun 1, 2009
    Messages:
    3
    Hi I'm new to VHDL, I'm thorough with all the basics of VHDL, now the task at hand I have is - to convert this piece of C code (Below) into a synthesisable VHDL code.

    The C -code is, to binarize a given gray scale image, to do that I have to first find out the histogram (Easy and I could do it), second a threshold value, which I will use to classify the incoming pixel value whether it is above or below the threshold value and last send out the new pixel value.

    For eg -
    If threshold = 128
    Incoming_pix = 56 Then outgoing_pix = 0
    Incoming_pix = 200 Then outgoing_pix = 255


    The thing which gives me creeps is the Division and Multiplication operations, Floating point arithmetic operations, Log function, how will I implement all that in VHDL?

    Do I need to design a multiplier/divider, or should I have to ignore float and just go for whole numbers? How will I implement log function in VHDL, any alternative you guys can suggest?

    Please give me some tips/pitfalls that I have to look out for, before I start designing this-

    Is the problem as as tough as it is appearing?:-(

    Thanks a lot!!!

    ***********C - Code************

    NHIST = 256;

    for (y = 0, n = 0; y < height; y++) {
    for (x = 0; x < width; x++) {
    iHist[imgIn[y][x]]++; // Histogram of the pixels
    n++; // n = Number of pixels
    }

    /* compute probabilities */
    for (i = 0; i < NHIST; i++)
    prob = (double) iHist / (double) n;

    /* find threshold */
    for (i = 0, Hn = 0.0; i < NHIST; i++)
    if (prob != 0.0)
    Hn -= prob * log (prob);

    for (i = 1, psiMax = 0.0; i < NHIST; i++) {
    for (j = 0, Ps = Hs = 0.0; j < i; j++) {
    Ps += prob[j];
    if (prob[j] > 0.0)
    Hs -= prob[j] * log (prob[j]);
    }

    if (Ps > 0.0 && Ps < 1.0)
    psi = log (Ps - Ps * Ps) + Hs / Ps + (Hn - Hs) / (1.0 - Ps);

    if (psi > psiMax) {
    psiMax = psi;
    thresh = i;
    }
    }
    //******* End of C- code************
     
    vikramtheone, Jun 10, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris
    Replies:
    2
    Views:
    352
    Kevin McMurtrie
    Mar 9, 2005
  2. Hubert Hung-Hsien Chang
    Replies:
    2
    Views:
    523
    Michael Foord
    Sep 17, 2004
  3. =?ISO-8859-1?Q?Rapha=EBl_MARC?=

    Processing an image with numarray.nd image

    =?ISO-8859-1?Q?Rapha=EBl_MARC?=, Oct 4, 2005, in forum: Python
    Replies:
    1
    Views:
    543
    Matt Feinstein
    Oct 4, 2005
  4. polemon
    Replies:
    4
    Views:
    498
    zeppe
    Jul 22, 2007
  5. alangs

    help in image processing....

    alangs, Sep 16, 2010, in forum: VHDL
    Replies:
    0
    Views:
    558
    alangs
    Sep 16, 2010
Loading...

Share This Page