LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Median value of an image


@AnttilaL wrote:
Image data being processed is in many test points mean of multiple images (to cancel noise). Thus double is only option to maintain the non-integer values.

You can do the averaging by summing in U32 with plenty of headroom and do a integer division at the end. I doubt it would change the result much, especially if the noise is significant.

Alternatively, SGL has a 23bit mantissa, which is sufficient to hold tons of U16 averages. DBL is certainly overkill and uses twice the memory.

Message 11 of 15
(1,426 Views)

@altenbach wrote:

@AnttilaL wrote:
Image data being processed is in many test points mean of multiple images (to cancel noise). Thus double is only option to maintain the non-integer values.

You can do the averaging by summing in U32 with plenty of headroom and do a integer division at the end. I doubt it would change the result much, especially if the noise is significant.

Alternatively, SGL has a 23bit mantissa, which is sufficient to hold tons of U16 averages. DBL is certainly overkill and uses twice the memory.


SGL or U32, still I don't understand how I'm consuming 3 GB RAM after loading around 30 images (IMAQ Create -> IMAQ ImageToArray -> IMAQ Dispose) and performing analyzes such as median, standard deviation, summing + mean image calculation for respective arrays?

 

With "Request Deallocation"s' test sequence can run 10 times and memory usage holds between 500mb-800mb before LabVIEW tells "Memory is Full". Without "Request Deallocation"s' test sequence can't even run one time before LabVIEW will tell "Memory is full".

0 Kudos
Message 12 of 15
(1,410 Views)

@nanocyte wrote:

I think what you're doing in the in place structure is the leak. Here's two options that shouldn't go mem crazy. Try both.

undefined


In general how come in place is leak if it modifies the very same array in memory instead of creating copies of them? If you compare code in my example and your example, your example is actually making more buffer allocations than mine.

0 Kudos
Message 13 of 15
(1,403 Views)

I don't know quite how to answer you without a high degree of handwaving. I don't know what's causing your memory leak. The in place does not guarantee that you won't have a memory leak because you can grow your array in there or create new arrays in there. The buffers are only an indication of possible memory usage. The actual memory use varies. Benchmarking and trial and error is probably a better way to reduce memory usage.

 

I benchmarked my median code and it ran indefinitely and did not have a memory leak. It uses 66MB of memory in 2011 regardless of how many times it ran. LabVIEW is using ~300MB in task manager.

undefined

Here's how I benchmarked it:

undefined

 

 

0 Kudos
Message 14 of 15
(1,389 Views)

Old thread I know, but I was looking for a way to find the median within a IMAQ ROI. Since I couldn't find anything I decided to try myself. Maybe it can be of use to someone else too.

 

Median within ROI.png

Download All
0 Kudos
Message 15 of 15
(899 Views)