how determine head light on car

2 visualizaciones (últimos 30 días)
ali
ali el 13 de Nov. de 2023
Respondida: ali el 16 de Nov. de 2023
hi my teacher ask me determind car's headlight in picture on matlab and draw circule on thoes and measure distance between thoes how can i do it ...please help me
thanks in advance.
  3 comentarios
ali
ali el 15 de Nov. de 2023
Editada: ali el 15 de Nov. de 2023
hi first of all i appricate for answer my question .i try to found car's headlight that is 200 meter far away from my car..i know how to determine distance car that is far away from my car but i want to recognize headlight in picture and measure distance between of them.i wrote my code that did it but some noise exist on it that i could'not remove it . i attach my picture and result of my code ..please give guidline how to remove noise that distrubed me ...i need to circle that are up in image and smaller than are on floor
i = imread('C:\New folder\ahb27.jpg');
subplot(2,3,1),imshow(i);
title('image');
% % Convert the image to grayscale
grayImage = rgb2gray(i);
% % Display the grayscale image
subplot(2,3,2),imshow(grayImage);
title('gray scale image');
imhist(grayImage);
subplot(2,2,3),imshow(grayImage);
n = 2;
Idouble = im2double(grayImage);
avg = mean2(Idouble);
sigma = std2(Idouble);
K = imadjust(grayImage,[0.7 0.8],[]);
figure
se = strel('disk', 5); % Adjust disk size as needed
cleanedBinaryImage = imopen(binaryImage, se);
imshow(cleanedBinaryImage);
Rmin = 5;
Rmax = 20;
[centersBright, radiiBright] = imfindcircles(cleanedBinaryImage,[Rmin Rmax],'ObjectPolarity','bright');
viscircles(centersBright, radiiBright,'Color','b');
DGM
DGM el 16 de Nov. de 2023
You might try a number of things. I can't think of anything that would be universal, though.
You might try sorting bright spots based on their y-position, but that would get fooled by streetlights, clearance lights, and other cars.
You might try some sort of clustering to associate bright spots with their own reflections and then sorting within those groups to exclude the reflections. That could probably be defeated by a little rain or fog.
inpict = imread('ahb27.jpg');
% create a mask somehow
% i'm going to use HSV only because there is some
% color information which might help subdue the penumbra
% but S information is extremely damaged due to the downsampled chroma
[~,S,V] = rgb2hsv(inpict);
mask = S < 0.05 & V > 0.98;
% get blob area and position
% include an index list, so that it gets transformed during sorting
PS = regionprops(mask,'area','centroid');
A = vertcat(PS.Area);
C = vertcat(PS.Centroid);
roiblobs = (1:numel(PS)).';
% discard small objects
% i'm just going to use the median
% but there's not universally appropriate
junkblobs = A<median(A);
C(junkblobs,:) = [];
roiblobs(junkblobs) = [];
% sort blobs by y-position
[~,idx] = sort(C(:,2));
C = C(idx(1:2),:);
roiblobs = roiblobs(idx(1:2));
% if we want to truncate PS or A, we can
% similarly, the excluded objects could be removed from mask
PS = PS(roiblobs);
A = A(roiblobs);
% plot it i guess
% i'm calculating R based on A
imshow(mask,'border','tight')
viscircles(C,2*sqrt(A/pi));
% distance between blob centroids in pixels
D = sqrt(sum(diff(C).^2))
D = 23.1107

Iniciar sesión para comentar.

Respuestas (1)

ali
ali el 16 de Nov. de 2023
yes your anwser is correct. i surface web and i understood i need to impelemetation of neural network like semantic segmentation and use it in my task ..because of change in some parameter can affect on my progaram and won't ork properly like viberation and etc...what do you make of my opinion ...are you agree this progaram won't work...???thanks for effort and helping...

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by