LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Averaging values in 2-D Array in a circular area

Solved!
Go to solution

I would like to pick-up Altenbachs first idea to use a mask and my suggestion to reduce computing effort using a subarray from the input data (image). Please find attached a LV 8.5 Version. I guess it will also solve indrajits question.

 

Compared to Altenbachs  my VI hasn't such a nice GUI. You have to type in some coordinates on the front panel. Ellipses and rectangle are defined by two opposite corners (for ellipses i.e. the corners of the smallest rectangle enclosing the ellipse).

 

In principle also abitrary masks can be processed.

 

Some explanation:

  Block diagram:

     - in the upper case structure the type of ROI is selected. The meaning of the coordinates can be different for each ROI type.

     - below the case structure all coordnates are scanned for minimum and maximum value for x and y-direction. These values define a bounding rectangle which cut the Raw Data.

 

Regards, Jörn

0 Kudos
Message 21 of 38
(3,712 Views)
Solution
Accepted by topic author sophia2008

Here's a quick draft. Since we are indexing over the subarray, we need to also check that we are in range. A simple range check on the indices would do, or we can do something like in the attached.

 

Your image is RGB, so you need to decide how to deal with the three color components. For simplicity, I only used the R here.

 

You could also use an image indicator for interaction and selection, it's probably easier.

 

(Or you could use "plot images" overlay to draw the circle on the main graph. )

 

Message Edited by altenbach on 07-03-2009 09:06 AM
Download All
Message 22 of 38
(3,698 Views)

Nicely DONE

 

Asuming, [ Ah, ... Certainment!,] that you haven't relegated me to the "class"of posters that claim "'Minor points' of "Math" (like the trivial, but demonstarable, difference between mu and Bar over Chi)'" are without defense.

 

Good Lord--- My "Lovely Wife" has a Masters degree in "English" ((please help me???)) I cannot punctuate without refering to J. Swift's "G*'s 'Travaille's"

 

Honey-----Is this a run-on sentance?--- OK, can you ask C. S. Lewis if I should set (this) phrase off with parenthesises?

 

LOL (seams a lot simpler don't it?)

 

{Honey?.... Honey... did your heart skip a beat when you read "don't it"?}

Message Edited by Jeff Bohrer on 07-08-2009 11:54 PM

"Should be" isn't "Is" -Jay
0 Kudos
Message 23 of 38
(3,661 Views)

To altenbach:

Have you noticed, that in your solution the selected pixels shown in the Subset-Intensity Graph are not always regularly shaped?

E. g. a radius of 2.7933 or 5,02793 are not symmetrical in vertical and horizontal direction. Or look at  11,7318 where it seems as if some additional pixels should belong to the select area.

 

In one of your former posted VIs I found that the cursor is not sitting exactly in the center of the selected pixels. It is half a pixel off.

 

From the ImageVision point of view I would expect that the selected area is always symmetrical as the pixels positions are discrete (integers) with no in between (like with floats).

 

Regards, Jörn

0 Kudos
Message 24 of 38
(3,648 Views)

Jörn wrote:

To altenbach:

Have you noticed, that in your solution the selected pixels shown in the Subset-Intensity Graph are not always regularly shaped?

E. g. a radius of 2.7933 or 5,02793 are not symmetrical in vertical and horizontal direction. Or look at  11,7318 where it seems as if some additional pixels should belong to the select area.


My post was just a crude draft. I am sure you can tweak it to your exact needs if things like that matter. Of course a noninteger radius seems a bit overkill. 😉

 

If you are really worried about subpixel resolution, you could average partial pixels along the edges using bilinear interpolation, for example. 😄

0 Kudos
Message 25 of 38
(3,640 Views)

Typically, it would be simpler to use an image indicator for user interactions. Here's a quick example.

 

 

 

It's probably buggy and needs to tweaked for the exact desired behavior. 🙂

Message Edited by altenbach on 07-09-2009 11:30 AM
Download All
Message 26 of 38
(3,626 Views)

altenbach wrote:

It's probably buggy and needs to tweaked for the exact desired behavior. 🙂


Sorry, I attached the wrong subVI to draw the decorations (Orignally, I allowed elliptical areas, that why I did a polygon). All we need is draw three circles, of course.

 

(Of course, it could all be done in a single loop with a single draw circle instance, but it would complicate other data structures. Modify as needed.)

Message Edited by altenbach on 07-09-2009 11:55 AM
0 Kudos
Message 27 of 38
(3,619 Views)
I would be interested in a performance comparison: Searching the complete array compared to cutting out a subarray a multiply with a mask. Lets say 600 images with 40 ROI each about 20 pixels in diameter (That are parameters from an application I am currently working on). Anyone out there? But I am not the one who started the thread.
0 Kudos
Message 28 of 38
(3,606 Views)

Altenbach

 

 

                       thanks , for the above work.. but i am not using a image. i just want to use a 103 X 103 sized  (dbl )matrix  which is having some data which i used to plot using intensity graph. where the a simallar circle has to move over the  intensity graph..not over the picture.

------------------------------------------------------------------------------------------------------------------
Indrajit

| indrajitbarve@gmail.com | indar_indar2005@yahoo.co.in .
0 Kudos
Message 29 of 38
(3,595 Views)

(That was only code I needed for my own work and I thought I share it.)

 

You can always display your 2D data as an image, it makes the interactive selection code a bit simpler. We have already posted how to do it with an intensity graph. You could combine the two and draw the circle using "plot images". Same difference. 😉

 

With an intensity graph you need to ensure that the pixels are square, i.e. the x and y axes should be of equal lenght, else the circle would turn into an ellipse. 😉

Message 30 of 38
(3,589 Views)