02-02-2009 08:56 AM
Hi All,
I'm trying to extract the 'lines' (just to clarify - the really really dark blue or black ones) from the attached JPG into a 2D array with the X and Y values (or a 1D array of Y values as the time step of x is constant). I'm not sure if I'm going to need some image processing stuff (I currently don't have IMAQ) or whether there is a simple neat trick to solve this.
By the way, this is a really clean nice image - you should see some of the other ones that I have, so I need something that is somewhat 'intelligent' and can fill in the blanks if things get a bit noisy.
Dr Phil
02-02-2009 09:45 AM
therealkilkenny wrote:Hi All,
I'm trying to extract the 'lines' (just to clarify - the really really dark blue or black ones) from the attached JPG into a 2D array with the X and Y values
Do you absolutely have to get it from an image? You can't get that data elsewhere? If it does have to come from an image, can you influence what it looks like? for instance, those horizontal lines in the image might cause you serious headaches, it would be easier if they weren't in there. Also, jpeg is a "lossy" codec, that creates lots of noise, especially at lower qualities
(or a 1D array of Y values as the time step of x is constant).
Looking at your picture, I'd say some x-values have 2 y-values that would be part of the line, so that won't work.
By the way, this is a really clean nice image - you should see some of the other ones that I have, so I need something that is somewhat 'intelligent' and can fill in the blanks if things get a bit noisy.
After getting rid of the horizontal lines, you could try to just keep everything below a certain threshold of blue and remove everything else?
02-02-2009 10:10 AM
02-02-2009 01:07 PM
Hi Guys,
Thanks for the suggestions. I have tried these and infact i createded a version of this image using a threshold and created a black/white output that looked good, but didn't really solve my problem.
The problem is that when i threshold the info in the picture (which is just a graphical representation of a 2D array by the way) there ends up being glitches in the data (i.e. gaps in the line - it's not continuous). What i would like to do is to detect the line in the picture and draw a line through 'gaps' and bits that don't look so good. What i think i need to do is to 'detect' the line, or curve fit a line to the data so that any glitches are filtered out and i get a continuous line of Y values for X values (i want only one Y value for every X).
I hope that helps.
Dr Phil
02-03-2009 12:28 PM
Hi Dr Phil,
Thanks for the post.
This is an interesting issue - which I am looking at the moment. I think this will be harder without the IMAQ, is there a reason for this?
I have currently converted the image to black and white and removed the hoz lines. Maybe the easiets aspect of this problem.
To fill in the missing gaps in the lines, which are more apparent when converting to two tones will be harder. There is no rule which will allow us to easily evulate a) where the linee gaps areand then b) to know which pixels to alter the value off.
However, I have seen curve fitting done to images not using IMAQ - so I will look into this more tomorrow. Do you have any ideas how you would think about going about this?
Lastely, I was wondering how you get to that image of data - maybe we can think of a better way to avoid the need for this.. more information would be great!
Kind Regards,
James
02-03-2009 02:27 PM
Hi James,
Thanks for getting back to me. Actually the picture is a screen dump of a 2D array on an intensity graph with the horizontal lines highlighted (so they aren't actually part of the data 🙂 sorry about that.
I just don't have IMAQ at the moment so if IMAQ will solve all my problems then i'll have to look into it.
The data that is shown in the graph is exceptionally 'clean' data. I thought it would be best to walk before i try and run. The dark line is if you like a valley running through an otherwise flat landscape. What i need to do is to plot the course of a river flowing through that valley (i.e. the minimum point). This is fairly easy using this data as it is exceptionally clear what is valid data and what is not. What becomes more difficult is when the 'valley' dissappears from view for a few moments and then reappears. Hence the idea to curve fit to this data (other graphs can look very different).
One bit of information that we can use is that there will be a limit to the slope of the curve, so we may be able to use that to predict limits wherein the 'valley' should flow next.
I hope this helps. I'll try and write more tomorrow and perhaps include more data.
Dr. Phil
02-04-2009 09:39 AM
Hi Dr Phil.
I hope your well.
Id be more than happy to work with you on this issue. If you could please send me the data - 2D array that would be great.
I can work on an IMAQ and math solution - or at least think it through some.
On the image - could you point of the river your seeing.. and maybe on another image show this disappearing?
Thanks,
02-04-2009 02:38 PM
Hi Dr Phil,
I hope your well.
I was just find a resource on ni.com and thought of this post - I think I have found the process we require. So we kind of covered the steps, taking an image, somehow getting a line (points) and then curving fitting it to complete the line (edges). Well..
Overview of Curve Fitting Models and Methods in LabVIEW
Link: http://zone.ni.com/devzone/cda/tut/p/id/6954
Edge Extraction:
This is what we need to do, the article explains basically that in digital image processing, you often need to determine the shape of an object and then detect and extract the edge of the shape. This process is called edge extraction. Inferior conditions, such as poor lighting and overexposure, can result in an edge that is incomplete or blurry. If the edge of an object is a regular curve(?), then the curve fitting method is useful for processing the initial edge.
To extract the edge of an object, you first can use the watershed algorithm. This algorithm separates the object image from the background image. Then you can use the morphologic algorithm to fill in missing pixels and filter the noise pixels. After obtaining the shape of the object, use the Laplacian, or the Laplace operator, to obtain the initial edge..As you can see from the previous figure, the extracted edge is not smooth or complete due to lighting conditions and an obstruction by another object (like the river disappearing!)
You maybe able to find these algorithm's in a form to generate yourselve, but I have found that these are in the Vision Development Module. The following article has an example which demonstrates a watershed transform as part of a morphological segmentation process.
Morphological Segmentation Example
Link: http://zone.ni.com/devzone/cda/epd/p/id/5718
Vision Development Module Evaluation Software Request
https://lumen.ni.com/nicif/us/evalvisiondevmodule/content.xhtml
I really think that the vision tools (maybe IMAQ rather than Vision Developemtn) could save you alot of effort here - what do you think?
I'll have another look again tomorrow about applying this in a more mathy method.
Hope this is good news,
02-09-2009 01:35 PM
Hi Guys,
Here is a bit more info. I've attached a couple of further images to illustrate what i need to detect and how it can get difficult as the SNR drops.
What your looking at in the first graph is a whole series of 1D arrays each one of which is a line in the y direction and one point wide in the x direction. Each 1D array is a measurement of successive measurements, and gives rise to the 'valleys' that we can see. The reason that i've gathered them alltogether like this is that it is easy to see what is happening and it is possible to extract out data even when the SNR gets low (for example in the region below y=50 in the top graph). You will notice in the bottom graph that there are lots of valleys that appear.
I've already tried some other methods in these posts:
http://forums.ni.com/ni/board/message?board.id=170&message.id=302779#M302779
http://forums.ni.com/ni/board/message?board.id=170&message.id=293793#M293793
In these posts i was approaching the problem from upside down - valleys were peaks and i was just considering one 1D array at a time. The problem was that when i got spurious peaks (or valleys in the current consideration) they messed up the results. Thus the approach to trying to pick out what is happening in the global picture.
The second attachment is a BMP file renamed as a DOC (just change the extension) and is a picture of my attempt in Paint to create some simple raw data that i can try and work on. I've written a rough VI to convert this 2D array into a 1D array and it works sufficiently well.
Any thoughts gratefully recieved.
Dr. Phil