Problem with overlapping line on image

1 次查看(过去 30 天)
I have an image.I have a line .I want to overlap this line on the image. I tried using the below lines.But I am seeing both separate. imshow(x);hold on; houghline(x,r,theta);
Any suggestions please?
Thanks, Mary

回答(1 个)

Sudhanshu Bhatt
Sudhanshu Bhatt 2015-10-28
Hi Mary,
It will be helpful if you can explain what workflow are you trying to achieve? Do you need to just plot a line on the image? Or the requirement is to highlight a line segment extracted by HOUGHLINES function?
Case 1: To draw a line on an image can be done from the code below:
% Read an image, create figure and show an image on the current Figure
% The image is provided with MATLAB, it can be found by executing
% >> which -all autumn.tif
img = imread('autumn.tif');
figure, imshow(img);
% Use hold on so we can retain current plot while plotting line
hold on;
% Plot the new line
plot([0,200],[10,200],'Color','r','LineWidth',2)
%Removing hold on the current plot
hold off;
Case 2: If you want to extract line segments based on Hough transform using HOUGHLINES and highlight them by drawing a line on the plotted image, please follow the example mentioned in the link below:
If this does not resolve your issue, please create a Technical Support Request by visiting the link below:
Thanks
Sudhanshu Bhatt

Community Treasure Hunt

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

Start Hunting!

Translated by