08-07-2025 05:54 AM
Hallo,
I would like to filter noise images. Here is one of my images and the result after filtering the image with the Vision Assistant. I would like to filter the separated cells as much as possible but the noise generated by the fluid flow as a background could not be filtered. I would like to delete the the lines of the fluid flow from the image. Could you please assist me or advise me? Thank you!
08-07-2025 08:47 AM
Since you are using modules, the machine vision forum might be more appropriate for your question. We also cannot tell what kind of settings you are using in the vision assistant. Typically a screenshot of the panel does not really tell us much.
Still, a greyscale image is just 2D data and it is possible To use plain LabVIEW tools to do all processing. Obviously, simple thresholding is not suitable but there are other obvious distinction between objects and background. In general, the more we know about the objects, the better the detection. Are the objects always the same size? Is the background always horizontally banded? Do you really need an image output or would just e.g. counting the objects be sufficient?
08-07-2025 09:38 AM
Here's a quick attempt subtracting a least absolute residual polynomial fit from each row, followed by thresholding at 30.
08-07-2025 12:11 PM
Subtracting a background obtained by convoluting with a suitable horizontal kernel followed by another filter to remove single spikes seems to work quite well. You still need deal with edge effect on both sides and maybe tweak the two kernels, but overall it works quite well and is fast.
08-08-2025 04:44 AM
Thank you for your assistance! Is it necessary to ask the same question in the machine vision forum? The spherical objects are biological cells. In a microfluidic channel I put a suspension with cells and I make 7 images with 7 different microfluidic pressures. I've attached the first and the last image. At the beginning the cells are almost spherical but during the increase of the pressure they become more elliptical. The background is always horizontally banded. I need an image output in fact.
08-08-2025 09:04 AM
So this seems to work quite well on all your pictures. See if the code makes sense. A few things could be improved and tuned, of course.
The default values seem to work quite well.
Seems pretty fast...
08-09-2025 04:07 AM
08-09-2025 08:05 PM
@tiho_bg wrote:
- Could you please explain why do you use Sine Pattern VI? What is the purpose regarding image processing?
No reason except convenience. All you need is a useful kernel and you could easily use a Gaussian (or 2D Gaussian), but since these are infinitely wide, you need to truncate.
I take the square of the sine to drop more nicely to zero but other exponents can be used. Have a look here for some examples.
In this case we know that the background changes slowly with X and smoothing with a function that is wide in X will basically wipe out the sharp bubbles but have very little effect on the background. Taking the difference leaves only the bubbles above a given threshold. You'll still end up with occasional very narrow peaks (often single bright pixels) so the second convolution leaves only "bubbles" that are above a certain size.
You can definitely try to play with the parameters and see how they influence the result. Maybe even find settings that are better than my current defaults. Good luck!
08-12-2025 10:20 AM - edited 08-12-2025 10:21 AM
Thank you for your assistance!
Regarding your first solution because it is not so complicated, let me explain what I understood, please:
1. Take the image and convert it in pixmap. The value of each pixel is presented in a hexadecimal value (3 bytes).
2. Break the number into its component bytes and take the low order byte (word equal to 2 bytes in this case).
3. Break the number into its component bytes and take the high order byte.
As an example, if I have 616263. First I take low order byte equal to 6263 and then the high order byte is 62, right?
4. Take the sine wave (only the positive part using Sine Pattern VI) as a filter. The cycle is equal to 0.5 and on this way I take the half positive part of the sine wave. The number of samples is important because the sine wave become smooth enough when the number of samples increases. The sine wave is similar to the Gaussian filter, right?
5. Compute the square of the input sine wave array. Why?
6. Each element of the square of the input sine wave array is divided by the sum of all elements of the square of the input sine wave. Why?
7. Compute the convolution between the high order byte from 3 and the input sine wave from 6.
8. Subtract the high order byte (line 3) from the the result (line 7).
9. Compute a second convolution. Why?
10. Evaluate the result from line 9 and if the value is greater than the threshold, the value is equal to 1, otherwise the value is equal to 0.
11. Multiply the result from line 10 with 255. Then if the result is equal to 255, the pixel has a black color, otherwise the pixel has white color.
12. Create a number from the result regarding the line 11. I create a hexadecimal number from 3 bytes. All three bytes are equal, why?
13. The image has been filtered successfully.
08-12-2025 12:41 PM - edited 08-13-2025 07:22 AM
3. Since the image is greyscale, R=G=B and it does not matter which of the tree nonzero bytes we take. I take the green. You should not take the highest order byte of the four, because it is not used in a 24bit image. (LabVIEW is big endian, so the high order byte is on the left)
4&5. All we really want is a symmetric function. The sine drops quite steeply while the square of the sine tapers more nicely. We delete the first point which is zero to get a function that is symmetric. You could do a rectangular pulse which would just do a running average.
6. We need to make sure that the sum of all elements of the kernel is exactly 1. This way the scaling of the pixels remains the same during convolution. *e.g. if the sum of the kernel would be set to 2, the picture would get twice as bright, exceeding the range of U8)
9. The second convolution with a symmetric 2D kernel is a simple blurring function. It eliminates noise spikes, i.e. single pixels that are mostly surrounded by background will drop significantly, but cells (bright areas bigger than a few pixels) will remain bright. Just bypass the function and look at the result to see the difference.
11. A pixel of 255 is white and 0 is black. You have it reversed.
12. All bytes are equal because the picture is not color (see point 3 above).