![]() |
|
|
|
#1 |
|
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[i] = (double) iHist[i] / (double) n; /* find threshold */ for (i = 0, Hn = 0.0; i < NHIST; i++) if (prob[i] != 0.0) Hn -= prob[i] * log (prob[i]); 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 |
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DeepBurner Pro - IMAGE? | Terry Pinnell | DVD Video | 2 | 04-28-2006 08:44 AM |
| Image acquires Criterion | Goro | DVD Video | 2 | 08-04-2005 02:28 AM |
| Anamorphic downconversion, digital video essentials, my recent foray into videophile land, frustration and heartbreak | cg | DVD Video | 18 | 09-21-2004 01:30 AM |
| Advantage of 4:3 hdtv over old 4:3 | Adam Smith | DVD Video | 17 | 12-15-2003 07:25 PM |
| New Releases: Short Circuit, Kung Fu Series, Image Horror: Updated complete downloadbable R1 DVD DB & info lists | Doug MacLean | DVD Video | 0 | 12-13-2003 05:31 AM |