LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Contour Line function in Computational Geometry issue

Hello!

 

Somewhere in the forum I've read already, that the Computational Geometry functions are buggy. So maybe I found another one or maybe it is my misunderstanding of its proper work. The problem is simple: I create a 2d array of DBL, which is presented in the intensity graph. Then this array is used as entry to the Contour Line function. So in the first case the non-zero elements are identified as a single contour, whereas in the fully symmetrical case - as three different contours. In the attached pictures everything becomes clear.

 

I don't know how this function works, but my goal is identify these two combinations of non-zero pixels identically (as single contour line).

 

Changing the height of the contour or the value in the array elements do not lead to any result.

 

Maybe somebody has already encountered this issue?

 

P.S. The global goal is to find clusters of attenuated pixels on a CCD matrix. The Contour Line function is ideal for me in this situation.

 

Thanks in advance!

0 Kudos
Message 1 of 9
(926 Views)

Attach a VI!  We can do a lot more if we can run (and edit, and "play with") your code than we can by squinting at some pictures that may or may not show sufficient details ...

 

Bob Schor

0 Kudos
Message 2 of 9
(894 Views)

You have single-pixel points and thus no real area, just an outline. This seems to be an edge case that depends on the orientation of adjacent pixels and I am not sure if there is a right and wrong way for this scenario (... just that the current results may give a hint at the algorithm used ;)). Maybe start with re-sampling the input to more points.

 

On a related note, this VI is fully open source and you can drill down all the way to see what it does and how it does it. You could even use it as a template for your own version if you need something different. 😄


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 3 of 9
(891 Views)

Please, find my simple VI in the attached. It is LV2015, i'm not sure if the Computationl geometry functions are present in previous version. I can attach VI in more old version if necesary.

 

Thank you for the advices. You are right, the function has the code open and I can access to it. However, the structure if very difficult to understand. There is a VI, then a subVI, in this subVI there is a subsubVI, then a subsubsubVI etc etc etc...

 

I agree, that my situation is an edge case. However this kind of combination of pixels (or array elements which is the same) is just what I need to identify in my task. Other cases, when the pixels are not diagonal, but are in the same raw or in the same column, the built-in Contour Line function works well.

 

It would be cool to write my own similar code to search for adjacent non-zero elements in 2d array. However this task is close to the problem of searching local maxima. Looking in the Labview forum on this problem I understood, that it is not very simple to do. Actually, in some post somebody has already used this Contour Line function for local maxima search.

0 Kudos
Message 4 of 9
(879 Views)

@Costa_ wrote:

Please, find my simple VI in the attached.


Whenever you attach a VI, make sure that all controls have reasonable default data so we can run it immediately. All your arrays are currently empty and the height=0. (For each control. (1) fill with data, (2) right-click...data operation...make current value default. Save the VI at the end). (See also this idea)

 

So, if I understand this right, you are looking for clusters of faulty pixels, whatever that means. I still don't think that contouring is the correct procedure for that. Maybe you could do something with convolution and thresholding. What is the final data you want to get out of it? It seems wasteful to turn simple pixels into unwieldy multi-line segments on an xy graph.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 9
(871 Views)

@Costa_ wrote:

Somewhere in the forum I've read already, that the Computational Geometry functions are buggy.


Hi, Costa.  Thanks for attaching your VI.  You didn't provide any data, so I decided to write a little VI to generate some data (on the surface of a sphere).  However, in attempting to do this (very simple task), I had occasion to use some of the Computational Geometry functions, and found that the Help document for 3D Coordinate Conversion VI is 80% wrong when describing spherical coordinates (so your original premise, quoted above, may well be correct!).

 

I got so involved with documenting (and trying to submit a Support ticket by e-mail -- I've got multiple tickets, but usually do it by phone, except today is Sunday and tomorrow is a Federal Holiday, so I wrote the attached document).  

 

The function actually works, but you have to ignore the Help and do "what NI meant for you to do" (which if you've done as much Spherical Polar Coordinate work as I have, you know the "expected" calls and will not even read the incorrect documentation).

 

This probably is unrelated to your real question.  You can do one more thing to provide the last bit of help to us -- save your VI with data attached, so we can "see" what we are dealing with.  Here's how to do this:

  1. Make a copy of your VI (so you won't "mess it up").
  2. Call your copy, passing it the Data you want it to process.  Don't worry if it doesn't work -- we'll try to help you figure out why, but we need to examine the data.
  3. Look at the Front Panel of your VI.  The Array should now be full of numbers (the Data).  Click on the Array (be sure you have the entire Array, not just one element, selected) , go to the Edit Menu, and choose "Make Selected Values Default".  Save this Version With Data, and attach it (call it maybe "Contour Line with Data") in your reply.

Bob Schor

0 Kudos
Message 6 of 9
(863 Views)

Dear altenbach,


The final goal is the following. There is a raw data from CCD matrix - a 2D array. When a photon is incident onto the matrix, it leaves a track or a cluster of attenuated (non-zero) pixels. The number of incident photons per one frame is chosen in a way in order to exclude the overlapping of such clusters. In this case each cluster of attenuated pixels is surrounded by non-attenuated background pixels (their value is always equal to zero for my CCD). I want to identify every cluster and simply sum the values of all pixels in a single cluster.


Probably, the Contour Line function is not the best for this task. But excluding the described situation in my first message it works perfectly: I receive contours of all the clusters, and then I can simply check whether a pixel is inside or outside of the contour of a specific cluster.


Besides the VI with initialized default values (so you can play with), I also attach a sample image of raw data from CCD (a 40x40 pixels cut), where you can see, how the clusters are localized (the intensity graph on the left of the JPG image). On the right there is a Contour graph, processed by the Contour Line function. I marked by green on the left a single cluster, exactly with the situation as described in the first message. There are two pixels (the top and the bottom). Their diagonal position is symmetrical. As you can see, it is identified as two different contour, whereas it is a single cluster in my case. There are several such cases in the shown CCD data.


Unfortunately, because of this problem I loose some data.

 

P.S. The raw data with 2d array from CCD is also attached.

 

Thanks!

Download All
0 Kudos
Message 7 of 9
(853 Views)

I seriously doubt that (1) finding contours and then (2) figuring "inside" from "outside" is computationally efficient. The picture seems random enough that I doubt you can fully exclude overlapping traces. Why are the pixels not 0 or 1? Did the lighter pixels get hit by >1 photos? How can a single photon even leave a "track"??? I wasn't aware that a CCD can detect singe photons. Is there a PMT involved?

 

In any case, what you are looking for is "cluster analysis" And there are quite a few established algorithms, e.g. k-means. I would start there...


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 8 of 9
(845 Views)

You are totally right that from the point of view of computational efficiency this approach is inefficient at all) But it is not a problem for my amount of data.

The CCD that I'm working with is scientific level device with thermal cooling and amplification stabilization. The background in this case may be set very very low, that the ADC identify it as zero amplitude. The incident photon is not an optical but an X-ray one. It can penetrate deep inside the matrix and travel through several pixel, leaving a track of attenuated pixels. Their amplitude is not 1, it can vary depending on the deposited energy. So my goal is to retrieve the full energy of the incident photon to get its initial energy.

A picture, illustrating this process may be found here: https://damic.uchicago.edu/depot/images/detector-bkg.jpeg

I agree, that "cluster analysis" is convenient for this task. But my question was not about how to do this, but how you solved problem of the Contour Line function, if you have encountered the same effect of contour searching as me.

Thank you anyway.

0 Kudos
Message 9 of 9
(835 Views)