12

I am a novice user in image processing and working on a project to determine number of yarns in a fabric image i.e. warps and wefts (Perpendicular and parallel yarns to x-axis).

sample image

I am trying to detect the yarns by taking the sum of columns and rows for warps and weft respectively but it doesn't seem working because the image is not very well focused and sharp. Also the method is much sensitive to the alignment of yarns in the fabric.

Please propose a better algorithm if possible for detection of yarns. Also if there is any possibility to make yarns straight for every captured image. I have tried IMROTATE but it creates the black regions in image which disturbs the sum of rows and algorithm gets failed.

Any help in this regard will be of much worth to me. Thanks.

  • Use an FFT. Is this homework? – endolith Jul 08 '12 at 23:03
  • Yeah, a Fourier transform is probably the correct starting point. It would "pull" the regularity of the image out of the fuzziness. Not sure how to handle partial rotation, though. Maybe you could transform stripes and note their phase, then determine if adjacent stripes were skewing left or right. – Daniel R Hicks Jul 09 '12 at 00:41

2 Answers2

9

A fourier transform will give you the period of any periodic features in the image - eg it will tell you there is structure event 3pixels horizontally and 5 pixels vertically, from this and the pixel scale you can calculate the number of yarns

Martin Beckett
  • 834
  • 4
  • 9
3

Some code in Mathematica:

i = ColorNegate@Import@"https://i.stack.imgur.com/Jlhgw.jpg";
i3 = DeleteSmallComponents[Binarize[i, .4], 10];
lines = ImageLines[i3, .6];
Show[i, Graphics[{Thick, Orange, Line /@ lines}]]
(*y coord mean increments at x=0 *)
b = Mean@Differences@ Sort[(#[[2, 1]] #[[1, 2]] - #[[1, 1]] #[[2, 2]])/(#[[1,1]] - #[[2, 1]]) & /@ lines];
(*mean slope*)
a = Mean[-(-#[[1, 2]] + #[[2, 2]])/(#[[1, 1]] - #[[2, 1]]) & /@ lines];
(*Threads*)
- a ImageDimensions[i3][[1]]/b 
(*yarns*)
2 ImageDimensions[i3][[2]]/b

Result>

enter image description here

34.5541
27.2259

Dr. belisarius
  • 989
  • 1
  • 6
  • 9