Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Image Processing... need help

 
Thread Tools Search this Thread
Old 06-10-2009, 08:01 AM   #1
Smile Image Processing... need help


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
vikramtheone is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46