how determine head light on car
조회 수: 2 (최근 30일)
이전 댓글 표시
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
DGM
2023년 11월 16일
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))
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Camera Calibration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!