- Convert image to grayscale
 
- Detect Edges
 
- Compute the Hough Transform
 
- Identify peaks in Hough Transform
 
- Extract Lines and plot them: This is same as the code provided by you.
 

Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!