user5622144
user5622144

Reputation:

How to perform hough transform on canny edge image

After some pre- processing, edge detection and thinning i got the following image and the image is of type double

enter image description here

and in order to remove the isolated pixels within regions i used dilation as

se90 = strel('line', 2, 90);
se0 = strel('line', 2, 0);
BWsdil = imdilate(Edge, [se90 se0]);

vertical dilation followed by horizontal dilation

Actually i want to segment the objects which is labeled within rectangle(ellipse-like structure). enter image description here It is noticed that the black rectangle are ruptured during dilation if i increase the threshold i will lose the segment in the bottom rectangle. If i'm proceed with this result i'm end up in an error and even basic segmentation algorithms are not working without preprocessing. please help

Can your suggest any other technique to improve mask if i do connected component analysis on gradient image.i will get border of ellipse instead of ellipse as shown

i tried hough transform but i'm getting some bad results

close all;clear all
I=imread('Sub1.png');
load edge
rotI = imrotate(I,33,'crop');
[H,T,R] = hough(Edge);
imshow(H,[],'XData',T,'YData',R,...
            'InitialMagnification','fit');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
P  = houghpeaks(H,25,'threshold',ceil(0.3*max(H(:))));
x = T(P(:,2)); y = R(P(:,1));
plot(x,y,'s','color','white');
lines = houghlines(Edge,T,R,P,'FillGap',5,'MinLength',7);
figure, imshow(rotI), hold on
max_len = 0;
for k = 1:length(lines)
   xy = [lines(k).point1; lines(k).point2];
   plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');

   % Plot beginnings and ends of lines
   plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
   plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');

   % Determine the endpoints of the longest line segment
   len = norm(lines(k).point1 - lines(k).point2);
   if ( len > max_len)
      max_len = len;
      xy_long = xy;
   end
end

enter image description here

Upvotes: 1

Views: 751

Answers (0)

Related Questions