graphics recognition

Soldato
Joined
18 Oct 2012
Posts
8,334
so, have a bit of a challenge for you guys.

i have a series of images, many thousands, which are from a video tracking the growth of a crack. i can process these to be binary black/white pixels for clarity.

what i want to do is to track the movement of the crack, by counting the number of pixels from the fixed start point to the end of the crack. i need to do this for all the images and record the length (in pixels) versus picture number in some kind of text file.

anyone run into any (preferably open access) software that could do this?
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
can you post a colour original of a picture?

im not aware of any blackbox computer vision software. However if the area around the crack is largely seperable from the crack, e.g. an untextured smooth surface, then using OpenCv to code a very simple algorithm wouldn't take long.

the original recording was a grayscale, no colour on the camera but it looks something like this:
5q6S4Da.png

which i can convert to pure black/white like this:
qeFA8Ae.png

i plan to improve the surface preperation a bit in future, so the artefacts shouldn't be a problem.

This was my thought to on reading OP. Rather than trying to identify the crack and calculate it's length, could you simply count the number of black/white pixels and extrapolate the length from there.

this is exactly what i want to do, i can manually calibrate a scale from a single image (which is what the markings are for) so all i need is a plot of the crack length in pixels versus the image number, the rest is a case of synchronising it with the rest of the data in excel.
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
That's not what I meant, I was thinking of just counting the total number of black pixels in the entire image - no need for any image recognition or plotting lines on it. Having seen your image now, I dont think that'll work unless you can find some way to mask the background to white and still leave the view through the crack as black.

it might be possible to mask the outside. only problem is the crack grows over time, so the number of black pixels will be proportional to the area inside the crack rather than the actual length of the crack.
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
ok, so bit of an update to this.

i've managed to get the image isolated to show the crack as a singular object:
a9DYf83.png

do we think measuring the longest point to point distance would be doable?

i have literally zero coding experience so this is new ground for me.
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
guess the difficulty is determining the starting pixel to measure from, the ending pixel is fairly obvious(or near enough).

indeed, all i need is the line distance between the 2 furthest seperated pixels.

that image is the largest the crack gets, at the beginning it's a very thin line.

possibly starting at the first pixel from the right and measuring against the first pixel from the right until it's found the largest?
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
Just take the leftmost pixel and the rightmost pixel and calculate the distance between them.
It doesn't matter whether you use the higher or lower point on the left, before the crack formed those points were together so they will both be exactly the same distance from the end of the crack. (Although, in reality, the material can bend so each end point could be a different straight-line distance from the end of the crack. If you use the leftmost point then you should be measuring the straightest part of the material and getting the most accurate measurement of the crack)

yeah this is what i'm thinking.

in some of the tests the part tilts up or down, so it might pick the top or bottom interchangeably but as you say that linear distance is the length of the crack from the start point minus bending which is going to be as close as we can get to a true measurement of the crack length, plus you can see there's some artefacts that sporadically appear meaning we can't always measure from the same edge anyway.

the only problem really is this is well outside of my expertise lol.
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
that looks the ticket, does it just measure horizontally or is that just the specific image coming out as being horizontal?

if it's the latter then all i need is that, for all the images in (folder) with the distances as some kind of csv (anything i can open in excel) by image number/name
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
Actually horizontal or not doesnt matter. Its measuring between whichever points are leftmost and rightmost(of white pixels) on the x axis so should work regardless of the angle of the image.

May be a bit flawed if there are any white artifact pixels though which will throw the points out.

So rotated would measure this line
EEDUdMp.png

that's absolutely perfect, i'm working on making sure there aren't any artefacts in the image using the software i do have.

that tilt is you're showing there is worse than any of the real tests, so should work just fine.
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
Add a loop through your image folder, process each image, output to excel file with "closedxml".

(Using C# console app, which you can do for free with Visual studio community)

you may be underestimating how how bad my knowledge of all things coding is :p

*goes off to google visual studio community and c# coding for dummies*
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
Yeah I left them in in case I wanted to use them but didnt in the end.

Could use a load more images to actually test properly but I expect you could filter out any extreme anomalies in excel anyway.

how many you need? i have thousands :p

the single one i posted is the crack at full opening but the progression goes from a black screen with nothing through to that:

6vuZR6T.png
N1IZXW9.png
Wnb2ALb.png
a9DYf83.png

thats ~every 1k images in a series of 4000.

the crack does jump inside the space of a frame, but hopefully that should line up nicely with the load data from the machine (both the camera and the machine were running the same sampling rate)

fortunately these are very rough samples so i can figure out this analysis before using my good peices, so i should hopefully will be able to tweak the sample preperation and camera settings to get some better images.
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
6vuZR6T.png 0
N1IZXW9.png 38.20995
Wnb2ALb.png 114.3547
a9DYf83.png 572.0428

Is spot on from those 4 samples at least. :p

good to know.

i'm currently running it on the full batch, seems to be doing fine at the moment.

currently pretty excited to see how it turns out (yes i'm a massive nerd :p )

edit:

came out beautifully, there's a lot of noise in the chart but that's to be expected as the camera is barely picking up the crack edge but it seems to be doing exactly what the doctor ordered:

j5AGSrC.png

should be able to do a bit of smoothing on that, and some better image capture for future runs.

many thanks guys, this has been a great help!
 
Last edited:
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
so bit of an update to this.

for some reason it seems it doesn't want to run the code any more.

after some messing around i figured out how to fix the missing closedxml reference by installing the nuget closedxml add-in.

but now it's coming up with:
Code:
Error    CS0246    The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)    ConsoleApp8    C:\Users\wmose\source\repos\ConsoleApp8\Program.cs    18    N/A

any idea what's up?
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
ok, so the process as i've been doing so far:

new project in console app.net framework using default settings

paste code

under references- manage nuget packages, search closedxml and install the first one on the list:
Bhgs7bI.png

which after running build solution gives me this:
6zJZupE.png
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
you are indeed correct, apprently a chunk was missing. that's cleared up the errors.

when running it came up with "code exited with code 0" which i *think* is because the folder's images were .bmp rather than .png.

tried changing the format to .bmp and now it's doing something. saying parsing failed for the early images which i'm guessing is because they contain no white pixels.
 
Soldato
OP
Joined
18 Oct 2012
Posts
8,334
yeah it seems to be running fine with .bmp's, the output is pure black and white.

it seems to return 0 for the failed data points with no crack, which is perfect.

now all i need to do is run it on all the folders.
 
Back
Top Bottom