Randomized Hough transform (RHT) and Genetic Algorithm (GA)
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everybody,
I need to detect the edges in the following image, I used RHT (Randomized Hough transform) for detecting curves.
Here is the input (original) image:

Here is my code (RHT):
clear all
close all
clc
i = imread ('d (457).bmp');
ig = double(rgb2gray(i));
figure
imshow(ig, [min(min(ig)) max(max(ig))]);
h1 = fspecial('sobel');
h2 = h1';
igh = imfilter(ig,h1);
igv = imfilter(ig,h2);
igs = abs(igh)+abs(igv);
figure;
imshow(igs, [min(min(igs)) max(max(igs))]);
igsT = igs>110;
figure;
imshow(igsT);
acc = ([size(ig) 21]);
[r,c]=find(igsT);
iter = 0;
while (iter<200000)
iter = iter+1;
N = length(r);
ind = floor(N*rand(1,3))+ 1;
while(length(unique(ind))<3)
ind = floor(N*rand(1,3))+1;
end
% [x0,y0,R] = threepoints([r(ind(1)) c(ind(1))], [r(ind(2)) c(ind(1))], [r(ind(3)) c(ind(3))]);
x0 = [r(ind(1)) c(ind(1))];
y0 = [r(ind(2)) c(ind(1))];
R = [r(ind(3)) c(ind(3))];
x0 = ceil(x0);
y0 = ceil(y0);
R = ceil(R);
if (ismember(x0, [1 size(ig,1)]))
if (ismember(y0, [1 size(ig,2)]))
if(ismember(R, [15 25]))
acc(x0, y0, R-14) = acc(x0,y0,R-14)+1;
if(acc(x0,y0,R-14)>4)
s = fprintf('Found circle with [x0, y0, R] = [%d %d %d], press any key to continue\n',x0, y0,R);
disp(s)
hold on
cc = circle([y0, x0], R, 20,'-');
pause
end
end
end
end
end
RGB_Image = uint8( igsT(:,:,[1 1 1]) * 255 );
figure;
imshow(RGB_Image);
After running this code, I got the following result for RHT (for input original bmp image):

Whether this result is satisfactory or I need to increase the value of the threshold (currently 110)?
Also, i would like to ask if anyone has idea how RHT could be combined with a genetic algorithm (GA) in MATLAB, in order to get more efficient results compared to using only (RHT) or only GA (based on edge linking for edge detection)?
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Genetic Algorithm dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!