LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to filter noise images?

My example has three tunable controls (one has "width" in the name!) and a display selector. Just play around, change the values, and see what happens to the result!

 

altenbach_0-1755127379342.png

 

Message 21 of 41
(456 Views)

I would like to ask what is the difference between the symmetric kernel and the sine wave kernel that you are using? Is it possible to present the sine wave as a symmetric kernel or this is not necessary?

0 Kudos
Message 22 of 41
(411 Views)

@tiho wrote:

I would like to ask what is the difference between the symmetric kernel and the sine wave kernel that you are using? Is it possible to present the sine wave as a symmetric kernel or this is not necessary?


Ignoring elements that are zero, both kernels are symmetric. One just has an extra zero on the left which does not add to the convolution and is just ballast and we have one less point that actually contributes. (You can pad the kernel with as many leading and trailing zeroes as you want and the result will not change.)

 

As you can see, while both functions here have 11 points, the white one actually has only 10 useful points.

 

altenbach_0-1755268060288.png

 

(Really asymmetric kernels are of course useful in other situations, for example if your cells would look more like comets with a trailing tail on one side, for example.)

 

0 Kudos
Message 23 of 41
(395 Views)

Here is a simple example for 1D convolution. You ca see that if we use a normalized kernel (sum=1), the result will have the same integral. You can also see that broad features just get a bit rounded while sharp features drop significantly in amplitude, but retain the same area.

 

altenbach_0-1755270912917.png

 

0 Kudos
Message 24 of 41
(386 Views)

... and here's the same with a very asymmetric kernel.... 

 

(You can see that the peaks are no longer aligned but shifted to the right)

 

altenbach_0-1755271217173.png

 

0 Kudos
Message 25 of 41
(381 Views)

Thank you for your assistance!

 

I ma sending my last application, version 19.

 

Regarding your code, I see that the kernel that you using is an array with one row. Therefore I said that the kernel is not symmetric. The size of the kernel is 1 x 100 par example regarding the HkernelWidth. If I use a gaussian kernel from the Vision Assistant or regarding the theory, there are basic examples using kernels with size 3 x 3. 

 

Therefore I am asking about the sine wave kernel is it possible to present it in symmetric shape or it is not necessary? 

sine_wave_kernel.jpg

Here is the sine wave signal and the sine wave array that is not symmetric as I said.

 

My second question is related with the sum of the sum of the build array. Is it possible change the place of the sum as it is shown on the picture?

pic-kernel.png

 

 

Download All
0 Kudos
Message 26 of 41
(376 Views)

Your "background" is very blurry in x but has lots of relatively sharp transitions in y. We only want to blur in x to retain the sharpness in y The 2D shape should be based on the image and what we like to filter.

 

The sine kernel is symmetric once you remove the leading zero.

 


@tiho_bg wrote:

My second question is related with the sum of the sum of the build array. Is it possible change the place of the sum as it is shown on the picture?


Of course it is "possible" but would not be correct! The kernel needs to be normalized. If you normalize the convolution, the convoluted signal will no longer have the same integrated amplitude as the image before convolution!

 

Have you even tried??? If you normalize the background such that the sum of all elements is one, most, or all, elements will be much less than one and you'll end up with a black background image and no useful subtraction.

 

 

Message 27 of 41
(369 Views)

@tiho_bg wrote:

I ma sending my last application, version 19.


Sorry, I don't have any vision tools installed and cannot play with your VI.

Message 28 of 41
(355 Views)

In all web tutorials related with convolution kernels, the size of the kernel is equal to 3 x 3 (a square). In your code the sine wave kernel has a size equal to 1 x 100 (1 row and 100 columns). What is the difference between both sizes? I'm confused because of the sine wave kernel size!

 

Regarding the normalisation of the kernel I understood that this is a practice when working with image processing. Thank you for the clarification!

0 Kudos
Message 29 of 41
(348 Views)

A convolution with a 3x3 square kernel is the same as replacing each pixel with the average of the 9 closest pixels, which is just a mild noise filter (sometimes called a "box blur", see link below). A kernel that is tapered will do a weighted average where the weight decreases as a function of radial distance. Other kernels can do sharpening or emphasize edges. (I use it to simulate spin system spectra, nothing to do with pictures!)

 

Start reading here. If the image features (the background here) is asymmetric (slowly changing in X and sharper in Y as we have here), nothing is stopping us from using asymmetric and much wider kernels. Here we pick a width that completely obliterates the cells, but retains the background with little distortion. Have you tried playing with the controls yet as suggested? There is a reason they are not diagram constant!

 


@tiho_bg wrote:

Regarding the normalisation of the kernel I understood that this is a practice when working with image processing.


It is required for all convolutions (1D, 2D, 3D, etc.) if you want to keep the average brightness of the image, else you change the scaling of the signal. Of course there are exceptions where the kernel sum is equal to zero. For example a kernel of [x, -x] will take a scaled derivative of the signal.

 

You can make your own box-blur by iterating over each pixels using a stack of two FOR loops, take the 3x3 subset centered on it, take the average, and output a new value, creating a new 2D array at the indexing output tunnels. It will be tedious and slow. Convolution as implemented in LabVIEW does a multiplication in the Fourier domain which gives the same result, but is significantly faster for large datasets.

Message 30 of 41
(330 Views)