Direct Sun Detector code

조회 수: 10 (최근 30일)
Sameh Salman
Sameh Salman 2020년 3월 29일
댓글: Image Analyst 2020년 3월 30일
Dear All;
I have camera fixed in my office which capture image every 5 minute and the captured image sent to MATLAB, what is the best code to detect sun rays that passes through window?
if there is sun rays in office display ('direct sun') else display ('no direct sun')

채택된 답변

Image Analyst
Image Analyst 2020년 3월 29일
편집: Image Analyst 2020년 3월 29일
I'd take an image with the sun in view and then find out how bright it is and it's size. Then threshold the image and look for items roughly that bright and that size.
grayImage = rgb2gray(rgbImage);
binaryImage = grayImage > someValue; % someValue is some value that the sun is ALWAYS brighter than.
[labeledImage, numBlobs] = bwlabel(binaryImage);
props = regionprops(binaryImage, 'Area');
allAreas = [props.Area]
sunBlobs = allAreas >= minAreaForSun & allAreas <= maxAreaForSun;
if sum(sunBlobs) >= 1
% There is a sun in the image.
fprintf('Direct Sun at %s\n', datestr(now));
else
% There is no sun in the image.
fprintf('No Direct Sun at %s\n', datestr(now));
end
Attach photos of "with sun" and "without sun" if you need more help.
  댓글 수: 7
Sameh Salman
Sameh Salman 2020년 3월 29일
if the window is selected as the area of interest your code effectivly well be working for direct sun detection....
thank you very much for your support
Image Analyst
Image Analyst 2020년 3월 30일

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by