FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-27-2006, 10:29 PM
Michel Rouzic
Guest
 
Posts: n/a
Default Bi-dimensional time-domain convolution

Hi,

I have implemented 1D convolution in many ways before, in the
time-domain, by FFT, or by FFT with overlap-add, but I have never did
that in 2D until now.

I tried to but I have a problem that I just cannot solve. The vertical
convolution works properly, but the problem with the horizontal
convolution is that the last kernel_width-1 bins stay to 0. I'm pretty
sure that I have made a dumb mistake somewhere, but as hard as I tried
I couldn't spot it, so if I'm posting this here it's out of despair.

Context : the array ***image represents an image, the first dimension
being the colour layer, the two others being respectively the X and Y
axis. This image has been zero-stuffed in a previous function in order
to be filtered by the array *kernel, which represents a one dimensional
windowed-sinc function.

int8_t ***convolution(int8_t ***image, uint16_t image_width, uint16_t
image_height, int8_t *kernel, uint16_t kernel_width, uint16_t
*output_width, uint16_t *output_height, char sinc_scale)
{
int8_t ***output, *line;
uint16_t ic, ix, iy, ik;

*output_width = image_width+kernel_width-1;
*output_height = image_height+kernel_width-1;

output = malloc (4 * sizeof(int8_t **)); //allocation of the
zerostuffed result
for (ic=0; ic<4; ic++)
{
output[ic] = malloc (*output_width * sizeof(int8_t *));
for (ix=0; ix<*output_width; ix++)
output[ic][ix] = calloc (*output_height, sizeof(int8_t));
}

line = malloc (*output_width * sizeof(int8_t)); //allocation of the
horizontally convoluted result (one line)

for (ic=0; ic<4; ic++)
{
for (iy=0; iy<image_height; iy++)
{
for (ix=0; ix<image_width; ix++)
{
for (ik=0; ik<kernel_width; ik++)
{
line[ix+ik] += ( (int16_t) (image[ic][ix][iy] * kernel[ik])) >>
8-sinc_scale; //horizontal convolution
}
}
for (ix=0; ix<image_width; ix++)
{
for (ik=0; ik<kernel_width; ik++)
{
output[ic][ix][iy+ik] += ( (int16_t) (line[ix] * kernel[ik])) >>
8-sinc_scale; //vertical convolution
}
line[ix]=0;
}
}
}
free(line);
return output;
}

Thanks in advance

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
FFT and time domain amplitude after FFT convolution Michel Rouzic DSP 8 03-18-2006 03:15 AM
Some questions about transformation to time domain from freq. domain kawait DSP 0 10-24-2005 03:41 AM
Convolution of two one-dimensional arrays katz DSP 1 03-28-2005 06:15 PM
equivalent operations in the time-domain & the frequency-domain theColdest DSP 4 03-12-2005 08:57 PM
convert ferquency domain to time domain mulyo utomo DSP 1 02-02-2005 02:42 PM


All times are GMT +1. The time now is 02:11 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved