LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2d implementation of median filter for images

Solved!
Go to solution

I want to use the LabVIEW 1d median filter function for 2d array (image) application.  Vision does not have this function (or I cannot find it [using Vision 8.5]).  I am assuming I can apply the 1d median filter across the rows, then transpose the array, and apply again to the rows (really the columns but now rows because of transposition).   Just like for using the 1d FFT for 2d FFT.  Is this strategy correct?

 

Thanks,

 

Don

0 Kudos
Message 1 of 11
(11,053 Views)

No.

 

You need to define a window (X x Y pixels) and get a 2-D sub-array, reshape to linear, get median, and update the center pixel of your selection with that value.  Shift one pixel, repeat until the end of the row, shift down and repeat again until you have the full image.

 

It's really time-consuming.

 

Shane

Message 2 of 11
(11,041 Views)
Solution
Accepted by topic author DonRoth

It is there - IMAQ NthOrder under Image Processing:Filters.

NthOrder.png

By default, it takes the middle number of a 3x3 region around each pixel, but can be set to be the largest, smallest, or any rank in between.  Also has the flexibility of defining the size of the filter, although being a non-linear filter (hence why it's not separable as you suggest) the time required increases significantly.

 

Message 3 of 11
(11,028 Views)

Excellent find.  Further information on this fx:

 

"You can use this VI to apply a median filter by selecting the correct order, (f^2-1)/2, where f is the size of the convolution matrix." (A median (center-pixel) operation is advantageous because it standardizes the gray-level values without significantly modifying the form of the objects or the overall brightness in the image.).

 

So one only needs to specify the convolution kernel dimension, and can use the above equation to calculate order.  It was hard for me to believe that Vision did not have this function.  I now see that I should have searched the NI Vision for LabVIEW Help.  This is something I almost always do in addition to searching for the actual functions from the block diagram.  Had I done this, I would have found it.

 

Thanks again for looking.

 

Sincerely,

 

Don

 

0 Kudos
Message 4 of 11
(11,019 Views)

Folks - as an FYI, also note that Vision implements other non-linear filters using IMAQ EdgeDetection.

 

Sincerely,

 

Don

0 Kudos
Message 5 of 11
(10,997 Views)

I found another implementation of the image median filter.  It is located at:

 

\Vision Assistant 8.5\CG\iva templates lv85-vision85.llb\IVA GrayFilters - NthOrder.vi

 

This implementation is even simpler that the Vision fx because the only input is kernel size.

 

 

Don

0 Kudos
Message 6 of 11
(10,986 Views)
Really the only major limitation of this function is that it only supports a square kernel.  It would be nice to be able to wire in a binary array which specified which values to consider in the computation. For example [ [0 1 0] [1 1 1] [0 1 0] ] would only look at the values orthogonally adjacent.
0 Kudos
Message 7 of 11
(10,967 Views)
As an FYI, at least for linear filtering, IMAQ Convolute allows you to specify the kernel filter itself....Don
0 Kudos
Message 8 of 11
(10,947 Views)

hello,

please i have problem about choosing a suitable filter for medical image processing in labview

so,can you help me by giving me a filter's  name and how can i use it in labview ?

thank you

0 Kudos
Message 9 of 11
(6,242 Views)

hello,

please i have problem about choosing a suitable filter for medical image processing in labview

so,can you help me by giving me a filter's  name and how can i use it in labview ?

thank you

0 Kudos
Message 10 of 11
(6,233 Views)