WXforum.net
May 22, 2013, 01:53:18 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
Members: 6617  •  Posts: 178566  •  Topics: 18123
Please welcome TheMOX, our newest member.
Welcome to the the new hosting for WXforum.net.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Determining the amount of clouds during the day from a webcam image in C#  (Read 3730 times)
0 Members and 1 Guest are viewing this topic.
iisfaq
Christchurch Weather Live
Senior Contributor
****
Offline Offline

Posts: 172


WWW
« on: June 18, 2011, 11:56:16 PM »

I would like to write a function to help determine the amount of cloud cover in a day using the oktas ranges.

see http://worldweather.wmo.int/oktas.htm for Oktas scale.

My theory is that using a webCam image we could take a sky portion of the image (maybe the top 1/2) and then divide that into 16 squares.

From that we could reduce the colors in the image to 16.

We could then determine if the colors in the image are White, Silver, Grey, Blue or something else.

From this we could calculate the Oktas scale and also a cloud density value as well.

The Oktas scale really covers is there any blue in the area and if so what %.

If we had blue and white and gray then we have potentially a cloudy day with rain clouds?

Your thoughts on this approach?

I am trying at the moment to determine if a RGB Pixel is blue or not. Since to a human any share of blue is blue I need to reproduce that foruma in a function and even though it sounds easy I am not having a lot of luck yet.

Chris
Logged

wuhu_software
Forecaster
*****
Offline Offline

Posts: 682


WWW
« Reply #1 on: June 19, 2011, 11:10:26 AM »


That is an interesting problem. I suppose the first step would be to run the image through some type of pixel color classification algorithm. It seems there are a few different approaches out there for such a task. Searching Google, the Naive Bayes classifier algorithm or AdaBoost algorithm.

One area where these seem to be used frequently is in facial detection. Here is one page with some source, maybe you could pull out what you need to classify the colors extracting the blue pixels from the rest of the image:

http://www.hackchina.com/en/cont/90303

Here is another interesting paper on pixel color classification:

http://cseweb.ucsd.edu/~kastner/papers/fccm10-color_classification.pdf

Once you can classify the pixels, you could probably just compare the blue pixels to the rest of the data. The sun's effect might be a problem depending on where your camera is pointed.
Logged
KaliforniaKid
Member
*
Offline Offline

Posts: 7



« Reply #2 on: June 19, 2011, 12:37:54 PM »

not sure that I understand what you are trying to accomplish here. wouldn't it be just as good or better to have an actual webcam image to see weather it were cloudy or clear? or are you trying to digitize it somehow to convert to a numerical number you can input into a formula of some sort?
Logged
gwwilk
Southeast Lincoln Weather
Forecaster
*****
Offline Offline

Posts: 509



WWW
« Reply #3 on: June 19, 2011, 12:42:05 PM »

He may suffer from the same problem I do:  local NOAA METAR is loco.  It often says 'Clear' when it's cloudy, or 'Mist' when it foggy, etc.  My non-solution is to just put up with it and hope that my webcams and data can tell the real tale.
Logged

utahweatherbear
Senior Contributor
****
Offline Offline

Posts: 271



WWW
« Reply #4 on: June 19, 2011, 01:03:20 PM »

ASOS has its limitations. For sky, it first just looked straight overhead for conditions, now I believe it shoots up at 3 angles over time to make a guess. It also is augmented by humans at major airports. As far as mist/fog, that is based on prevailing visibility. It will go with BR(mist) with vsby ...crap can't remember exacty... over 1 mile I think, but FG(fog) less than that. My exact numbers may be off but you get the idea.
Logged

Mikla
Member
*
Offline Offline

Posts: 16


WWW
« Reply #5 on: November 01, 2011, 04:54:22 PM »

So I saw this thread and thought it would be interesting to throw a quick app together to see what came of it.  The app takes an image like:



and processes it by eliminating colors accept those that may be clouds:



and then check which pixels in the image are not transparent.  Then do a simple calculation to determine the number of pixels that are not transparent.  In the above image, I end up with 27.8%.

vb .net code attached.
Logged

SoMDWx
Forecaster
*****
Offline Offline

Posts: 610



WWW
« Reply #6 on: November 01, 2011, 04:57:53 PM »

Here lies the problem:

Cloud Coverage is based on the largest percentage of cloud conditions across the sky. With that, you may only capure an image that shows clear skys but behind the camera, over 50% of the sky may become overcast (stratus, etc.). Given that, you have to look at the entire sky....

Jim
Logged

Jim Wyman
Certificate In Weather Forecasting Graduate, Fall '11, PSU
Creator of Scit Pro
Southern Maryland Weather
http://somdweather.com
http://scit.somdweather.com
SteveFitz1
Senior Contributor
****
Offline Offline

Posts: 171



WWW
« Reply #7 on: November 01, 2011, 05:43:29 PM »

He may suffer from the same problem I do:  local NOAA METAR is loco.  It often says 'Clear' when it's cloudy, or 'Mist' when it foggy, etc.  My non-solution is to just put up with it and hope that my webcams and data can tell the real tale.
I include a small PHP script on my page that tests several conditions (ie., temp, humidity, cloud base, barometer, rain, etc.) and then provide a 'Sky Conditions' on my web page. I currently test for 26 different combinations of conditions resulting in either Fog, Winter Mix, Cloudy, Partly Cloudy, and Clear. I differentiate Sky Conditions from Active Weather (Thunderstorm, Heavy Rain, Rain, Light Rain, Very Light Rain, and None.) I've been tweaking this script off and on for the last year, so now it's actually pretty accurate...at least a lot more accurate than the METAR from the local airport.

Steve
Logged
Mikla
Member
*
Offline Offline

Posts: 16


WWW
« Reply #8 on: November 01, 2011, 07:31:09 PM »

True... but with a little technology or the use of a PZT or 360 degree camera, you could probably get a pretty good estimate.  If combined with sat images, radar, UV and solar sensors from various weather stations... I bet it could be pretty accurate.

Here lies the problem:

Cloud Coverage is based on the largest percentage of cloud conditions across the sky. With that, you may only capure an image that shows clear skys but behind the camera, over 50% of the sky may become overcast (stratus, etc.). Given that, you have to look at the entire sky....

Jim
Logged

jmcmurry
Jim McMurry
Senior Contributor
****
Offline Offline

Posts: 255


Davis Vantage Pro 2 Plus Wireless.


WWW
« Reply #9 on: November 02, 2011, 06:58:34 AM »

He may suffer from the same problem I do:  local NOAA METAR is loco.  It often says 'Clear' when it's cloudy, or 'Mist' when it foggy, etc.  My non-solution is to just put up with it and hope that my webcams and data can tell the real tale.
I include a small PHP script on my page that tests several conditions (ie., temp, humidity, cloud base, barometer, rain, etc.) and then provide a 'Sky Conditions' on my web page. I currently test for 26 different combinations of conditions resulting in either Fog, Winter Mix, Cloudy, Partly Cloudy, and Clear. I differentiate Sky Conditions from Active Weather (Thunderstorm, Heavy Rain, Rain, Light Rain, Very Light Rain, and None.) I've been tweaking this script off and on for the last year, so now it's actually pretty accurate...at least a lot more accurate than the METAR from the local airport.

Steve

Steve,

That sounds very interesting.  Is it anything you'd care to share?

- Jim
Logged

SteveFitz1
Senior Contributor
****
Offline Offline

Posts: 171



WWW
« Reply #10 on: November 02, 2011, 10:37:55 AM »

Quote

Steve,

That sounds very interesting.  Is it anything you'd care to share?

- Jim

Hey Jim,

I'm happy to share it. Keep in mind this works well for my climate in East Texas, so I'm sure you'll need to do some tweaking for your location.

Steve
Code:
These are the variables used followed by the PHP code:
Rain rate is $zxv124
Cloud base is $zxv025
Temperature is $zxv007
Humidity is $zxv005
Dew Point is $zxv022
Barometer is $zxv023
Density Altitude is $zxv026
Active Weather is $smartfcsta
Sky Conditions is $smartfcstc

<?php
if ($zxv124 0.05 && $zxv002 5) {   
$smartfcsta "Thunderstorm";
} elseif (
$zxv124 0.40) {    
$smartfcsta "Heavy Rain";
} elseif (
$zxv124 0.12) {    
$smartfcsta "Rain";
} elseif (
$zxv124 0.02) {    
$smartfcsta "Light Rain";
} elseif (
$zxv124 0.00) {    
$smartfcsta "Very Light Rain";
} else {
$smartfcsta "None Reported";
}
if (
$zxv005 96 && $zxv025 100)  {    
$smartfcstc "Fog";
} elseif (
$zxv124 0.02 && $zxv007 35) {    
$smartfcstc "Winter Mix";
} elseif (
$zxv124 0.00) {    
$smartfcstc "Cloudy";
} elseif (
$zxv025 1450 && $zxv023 30.00 && $zxv005 86) {    
$smartfcstc "Cloudy";
} elseif (
$zxv022 62 && $zxv026 3500) {   
$smartfcstc "Cloudy";
} elseif (
$zxv005 69 && $zxv023 29.95 && $zxv026 1000) {   
$smartfcstc "Cloudy";
} elseif (
$zxv025 1500 && $zxv023 29.95 && $zxv005 75) {   
$smartfcstc "Cloudy";
} elseif (
$zxv026 < -200 && $zxv023 29.95 && $zxv005 70 && $zxv025 1000) {   
$smartfcstc "Cloudy";
} elseif (
$zxv026 && $zxv005 82 && $zxv025 500) {   
$smartfcstc "Cloudy";
} elseif (
$zxv026 < -500 && $zxv023 29.99) {   
$smartfcstc "Cloudy";
} elseif (
$zxv026 500 && $zxv005 90) {    
$smartfcstc "Cloudy";
} elseif (
$zxv026 200 && $zxv023 30.00 && $zxv005 50 && $zxv025 2000) {    
$smartfcstc "Cloudy";
} elseif (
$zxv026 1800 && $zxv023 29.95 && $zxv005 60) {   
$smartfcstc "Cloudy";
} elseif (
$zxv025 2000 && $zxv005 75) {   
$smartfcstc "Cloudy";
} elseif (
$zxv022 62 && $zxv023 30.00 && $zxv007 72) {   
$smartfcstc "Partly Cloudy";
} elseif (
$zxv022 62 && $zxv026 2550) {   
$smartfcstc "Partly Cloudy";
} elseif (
$zxv022 62 && $zxv025 1600 && $zxv007 72) {   
$smartfcstc "Partly Cloudy";
} elseif (
$zxv022 70 && $zxv025 4000) {   
$smartfcstc "Partly Cloudy";
} elseif (
$zxv026 < -200 && $zxv023 29.99) {   
$smartfcstc "Partly Cloudy";
} elseif (
$zxv026 < -1000 && $zxv005 62 && $zxv005 70) {    
$smartfcstc "Partly Cloudy";
} elseif (
$zxv026 1000 && $zxv005 75 && $zxv023 29.95) {    
$smartfcstc "Partly Cloudy";
} elseif (
$zxv025 3000 && $zxv005 60 && $zxv023 29.95) {    
$smartfcstc "Partly Cloudy";
} elseif (
$zxv022 55 && $zxv005 50 && $zxv026 2000 && $zxv007 75) {    
$smartfcstc "Partly Cloudy";
} elseif (
$zxv025 2000) {    
$smartfcstc "Clear";
} else {
$smartfcstc "Clear";
}

?>

Logged
jmcmurry
Jim McMurry
Senior Contributor
****
Offline Offline

Posts: 255


Davis Vantage Pro 2 Plus Wireless.


WWW
« Reply #11 on: November 03, 2011, 07:20:54 AM »

Thanks Steve, I'll convert to WD data and have some fun playing with it.

- Jim
Logged

Axelvold
Forecaster
*****
Offline Offline

Posts: 1702



WWW
« Reply #12 on: November 03, 2011, 01:33:04 PM »

Hi SteveFitz1
What should this be zxv002

Code:
if ($zxv124 > 0.05 && $zxv002 > 5) {

I cant find it here,

Code:
These are the variables used followed by the PHP code:
Rain rate is $zxv124
Cloud base is $zxv025
Temperature is $zxv007
Humidity is $zxv005
Dew Point is $zxv022
Barometer is $zxv023
Density Altitude is $zxv026
Active Weather is $smartfcsta
Sky Conditions is $smartfcstc

And what units are you using?
« Last Edit: November 03, 2011, 02:21:53 PM by Axelvold » Logged

Lars Magnusson
Axelvold / Sweden
55° 57' 41" N / 13° 6' 1" E
WX Station: Davis Vantage Pro2 Plus


SteveFitz1
Senior Contributor
****
Offline Offline

Posts: 171



WWW
« Reply #13 on: November 03, 2011, 03:17:00 PM »

Lars,

Sorry, I missed that one. zxv002 is Wind Speed. The units are:

Wind Speed: MPH
Rain rate: inches per hour
Cloud base: feet
Temperature: degrees Fahrenheit
Humidity: percent
Dew Point: degrees Fahrenheit
Barometer: inches
Density Altitude: feet

Steve
Logged
Axelvold
Forecaster
*****
Offline Offline

Posts: 1702



WWW
« Reply #14 on: November 03, 2011, 03:48:23 PM »

I cant find the tag for this in WD Density Altitude: feet, anyone that could tell me what it should be?
Logged

Lars Magnusson
Axelvold / Sweden
55° 57' 41" N / 13° 6' 1" E
WX Station: Davis Vantage Pro2 Plus


Weather Display
Forecaster
*****
Offline Offline

Posts: 2257


WWW
« Reply #15 on: November 03, 2011, 04:14:36 PM »

%airdensity%
or
%densityalt%
Logged

Axelvold
Forecaster
*****
Offline Offline

Posts: 1702



WWW
« Reply #16 on: November 03, 2011, 04:31:32 PM »

%airdensity%
or
%densityalt%

Thanks, one more question what unit is %densityalt% in?
Logged

Lars Magnusson
Axelvold / Sweden
55° 57' 41" N / 13° 6' 1" E
WX Station: Davis Vantage Pro2 Plus


Weather Display
Forecaster
*****
Offline Offline

Posts: 2257


WWW
« Reply #17 on: November 03, 2011, 04:51:55 PM »

Feet
and it uses the altitude setting (Ft) that you have entered in the sun moon rise/set setup as well
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.222 seconds with 19 queries.
anything