Detecting lines with houghlines in matlab I have This image which is basically made of sloped lines (almost horizontal and parallel)



I tried exactly the code in matlab documentation to detect those lines (except the rotation part) but I got a very strange result (vertical lines detected and no single horizontal line!):


I really can't find explanation of this output. I tried the same code on a different image and it was ok. I tried to change all the possible parameters in houghlines and houghpeaks but I always get vertical lines even though my image has no vertical lines or anything similar to be vertical!

I need to detect the parallel lines in the image or somehow get their slope. If you think there's something wrong in my image or additional modification I should do to the example code. or if you have any better idea that would be great!
The biggest issue is that the pixels for each line are too few (I will explain with more details below). I would consider to stretch, and then dilate your raw image a little bit:
file='http://i.stack.imgur.com/LmIJJ.png';
I=imread(file);
I=imcrop(I,[1 206 size(I,2) size(I,1)]);
I=imresize(I,[size(I,1) 256]);
I=imdilate(I,strel('line',1,0));

I assume you are using the sample code from Mathworks on hough, houghlines, and houghpeaks. The problem is that there are not very many pixels along one slope in your image. You feel like it is a line, but it is actually a curve that consists of many short lines with different orientation. I think one parameter that you need to tune is the 'FillGap' which will connect the very short segments. I tried:
lines = houghlines(BW,T,R,P,'FillGap',30,'MinLength',15);

And the image I obtained:


There is still plenty of room for improvement, yet at least most lines are detected.
Note that the theta-axis in hough peaks indicates the slopes of the lines, you may also check them from lines, T, and R. But since the image has already been stretched along the 2nd dimension of raw data, you may need to scale them back (with some tangent transformations) if you plan to get the slopes of those detected lines.
Hope it helps, thank you.