I have some Beta Radiographed papers which all have some vertical lines. I'd like to use the image processing capabilities of Mathematica to automatically detect these vertical lines.

The code which I wrote detects the lines, but when I run the same code on another set of data, I have to manually adjust the Binarize threshold to get decent results. I know I can use Manipulate but I want to save my time in checking each value to see if it detects the vertical lines.

Is there a way in which the operation of detecting these lines in all the beta radiographed data can be automated?

enter image description here

  • 4
    $\begingroup$ Since you are James Bond you might ask Q if he can do that easily. If not, I doubt there is a way to automate it. $\endgroup$
    – Öskå
    Commented Nov 12, 2014 at 12:02
  • $\begingroup$ Normalize = Normalize[{{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}}, Norm]; gives an error. $\endgroup$
    – C. E.
    Commented Nov 12, 2014 at 14:29
  • $\begingroup$ Sorry, you will need to change it to Normal = Normalize[{{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}}, Norm], Since Normalize is reserved. $\endgroup$
    – James Bond
    Commented Nov 12, 2014 at 18:44

1 Answer 1


This is not a complete answer, but I think you can build on this idea (I currently have no time to push it further).

Considering that the lines are really vertical:

imageData = ImageData[imgRaw];
data = Sum[First /@ imageData[[i]], {i, Length[imageData]}];

enter image description here

We can see that there are local minimums. I had no time to automate the detection of this local minimum (as per comments, in version 10, this should be easy with FindPeaks).

So, with no automation, I'm taking the minimums manually from the "get coordinates" tool:

linesCoordinates = First /@ {{58.11, 382.5}, {228.7, 361.2}, {391.6, 446.5}, {568.5, 
imageDataAux = imageData;
Do[imageDataAux[[All, Round[i]]] = {0, 0, 0}, {i, linesCoordinates}]

enter image description here

Looks promising. Obviously, reducing the analysis to an horizontal band that doesn't have the handwriting may help on the method precision. I hope this helps.

  • 1
    $\begingroup$ you say: "I had no time to automate the detection of this local minimum...". In MMA10 this can be done with function FindPeaks $\endgroup$ Commented Nov 12, 2014 at 13:36
  • 1
    $\begingroup$ @molekyla777 I know... But I'm still working with 9 (waiting for 10.0.2 to have 10 on my production machine) $\endgroup$
    – P. Fonseca
    Commented Nov 12, 2014 at 13:37
  • $\begingroup$ peaks = {#[[1]], -#[[2]]} & /@ FindPeaks[-data, 5, 2] works perfectly with your data! $\endgroup$
    – Aisamu
    Commented Nov 12, 2014 at 14:39
  • $\begingroup$ Hey, I tried the above info but got some error in data = Sum[First /@ imageData[[i]], {i, Length[imageData]}]; and in Image[imageDataAux] no image was displayed as an output. I then changed my data set and in other image there was no plotting in the listline. Can you help further? thanks. $\endgroup$
    – James Bond
    Commented Nov 12, 2014 at 18:47
  • $\begingroup$ @JamesBond sure. Can you send me one of the images by e-mail (see in my account)? That way, i'm sure we are seing the same thing. What M version do you have? $\endgroup$
    – P. Fonseca
    Commented Nov 12, 2014 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.