I am trying to detect horizontal and vertical striped patterns in cloth pictures. Two examples of pictures that should be detected are:

My first approach was trying to use a Hough Line detector. The problem is the clothes are often deformed or wrinkled so the lines aren't straight and the detector fails.
It can be assumed that the lines are horizontal or vertical with a deviation of a few degrees (horizontal and vertical striped patterns). Also that the lines are parallel
What would be a good approach to detect such slightly deformed lines?
I quickly tried this in Matlab. You can try it with opencv. Use reduce function to take the projections. Below is the Matlab code and some results:
im = imread('pRfUL.jpg');
gr = rgb2gray(im);
h = fspecial('sobel');
grad = imfilter(gr, h) + imfilter(gr, h'); % quick gradient
hpr = sum(grad);
vpr = sum(grad');
figure,
subplot(2,2,1), imshow(gr), title('gray scale')
subplot(2,2,2), imshow(grad), title('gradient')
subplot(2,2,3), plot(hpr), title('horizontal projection')
subplot(2,2,4), plot(vpr), title('vertical projection')

EDIT
One possible improvement would be to consider horizontal and vertical cases separately. So, there would be two passes through the image for each cases (this might perform better for noisy/textured cases, and as Nallath pointed out- I think he's referring to bilateral filtering-, you can use some additional filtering). That is, when you look for horizontal strips, use the horizontal filter which will give strong responses for horizontally oriented edges. Same for vertical case.
grad = imfilter(gr, h); % for strong horizontal responses in the above code. use grad = imfilter(gr, h') for vertical
The result for horizontal case: note that the horizontal projection and the vertical offset have dropped significantly

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With