LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need some help with Convolution

Solved!
Go to solution

I dont exactly understand what is going on with my convolution. I am trying to convolve my data with a {+1, -1} wavelet, downsample by 2, and convolve again.

 

The problem I am having is that if N values of data go in, it comes out with N+1 values. When I set up the VI to process a large data file using a loop, the issue becomes much much larger.

 

How do I solve the issue with my convolution? What do I have to do after convolving to eliminate the excess?

0 Kudos
Message 1 of 11
(4,103 Views)

Unfortunately, the 1D convolution (unlike the 2D convolution!) does not have an output control. As an alternative, you can write your own. Both the FFT and direct algorithm are quite trivial.

 

In the meantime, please support my idea to add output controls to the 1D convolution. 😄

 

(Only 3 votes so far. Nobody seems to care, maybe cause not many people use convolutions :()

Message 2 of 11
(4,087 Views)

You were already being helped in your original thread. Please don't create a new thread just to continue the same discussion. People will not know what has already been discussed. This means people will probably suggest something that may have already been suggested, and this doesn't help you.

 

You should keep the discussion in the original thread. In fact, Zach asked you what was wrong about the convolution, and instead of answering him you created a new thread.

Message 3 of 11
(4,084 Views)

So would it be better to convert my 1D data into a 2D and then use the 2D convolution?

 

I have tried to write my own convolution via FFT and Inverse FFT, but it just does not work out. I've put in both the block and front panel diagrams.

 

What do you mean by direct algorithm? I was under the impression that the FT method is the definition of the convolution sum? Is there another way to construct a convolution with 1D output control?

 

 

Sorry for reposting, it wont happen in the future.

Download All
0 Kudos
Message 4 of 11
(4,074 Views)

 


@Evilduck wrote:

 

What do you mean by direct algorithm? I was under the impression that the FT method is the definition of the convolution sum? Is there another way to construct a convolution with 1D output control?


The FFT method is just one way to do it. It is an algorithm, not a definition of the method ;). Have a look at my example (convolution.viposted here a while ago.

 

Message 5 of 11
(4,063 Views)

OK, to convolute with {1,-1} is much easier with the direct method. Much more efficient if you loop over the shorter array.

 

Can you attach your simplified VI containing some typical data.

 

Circular FFT convolution only works correctly if both array inputs have the same size. You are truncating the long fft to only 2 elements at the multiplication (the shorter transform wins!), throwing away most of the data. Think about it!

Message 6 of 11
(4,052 Views)

Altenbach,

 

I've tried running this through your explicit convolution calculation, and the extra term still appears in the sequence.

 

Here is my VI and some sample data.

 

The convololve file is one where I tried to run a 2D convolution, but when I restrict to Size X instead of full, the whole thing drops out.

Download All
0 Kudos
Message 7 of 11
(4,045 Views)

You are basically doing a first derivative of the data. There will be an "edge effect", because only N-1 elements overlap. This is expected and you need to decide how to deal with it. There are many possibilities.

Message 8 of 11
(4,029 Views)

There is apparently something wrong with the beginning?

I'm sorry, I start with N data values, and after the convolution, i have N+1. Is there any definite way to get N? what do i need to get rid of?

0 Kudos
Message 9 of 11
(4,023 Views)
Solution
Accepted by topic author Evilduck

As I said, a convolution with 1,-1 is just a simple derivative. I don't know why you would jump through all these flaming hoops of advanced signal processing, if all you need is a pairwise difference. Is somebody testing you? 😮

 

The attached modification shows what I mean. As you can see, the results are identical!

 

 

 

Download All
Message 10 of 11
(4,004 Views)