Jump to content
  • Advertisement
  • entries
    13
  • comments
    13
  • views
    14460

DevLog #8 - Bright & dark spots image detection

Sign in to follow this  
KaRei

943 views

The simple B&W image reading for generating galaxy arms presented in DevLog #7 showed up to be a bit too simple for my needs. I needed to reduce the thickness of dust stream within the arms. I've thought about another density map exclusively for the dust, but I needed larger resolution for it. And while I was thinking about what size would be good enought to depict the thin dust streams, I've reached a point where few pixels more or less on the image size wouldn't make already large difference. So why not use the colored source image I have there already instead of relying on some density maps?

And so the detection of bright and dark spots on an image taken from JPEG started.
On this enlarged fragment of the source image you can see the blur and noise I am standing against.

sourcexi.jpg

Bright spots


First step to detect any bright spot is to find local brightness maximums (pixels that are brighter than their surrounding pixels).
Then it must be determined whether it is a blurred dot (interested), a spill (not interested) or a noise (not interested).
I didn't make much elaborate detection mechanism in this. I just took close area surrounding the local maximum, calculated the average brightness of pixels in specific distances, and compared that with increasing distance from the maximum the brightness of pixels is decreasing. If yes, the local maximum is a center of blurred point.

byte pixelBrightness = pixel[ R ] * 0.2126f
+ pixel[ G ] * 0.7152f
+ pixel[ B ] * 0.0722f;
...

if ( pixelBrightness > maxSurroundingBrightness // Check there is no pixel around brighter than this one
&& avgCloseSurroundingBrightness > avgFarSurroundingBrightness // Check the brightness is reducing with greater distance
&& 0.9f * pixelBrightness > avgFarSurroundingBrightness ) // Checks the brightness difference is large enough enought (i.e. filters out a noise)
{
/// code for adding star
}


Dark spots

Now this was a challenge. Here are no dots I could easily detect (and if yes, they aren't interesting for my purpose). Everything - noise, areas between arms, areas outside the Galaxy, areas of dust - are dark spills. The only clue for detecting the dust I had was the color tone. The dust on the image is reddish or brownish, while other areas are bluish. So here I was reading color channels and comparing them against each other. The supperiority of red appeared to not immediatelly mean a red dust, but it could be an orange core, or some bright dot that was more to the orange. To filter this out I added weights for each color and later also a top limit for overall brightness of pixel, securing I will take areas that are much more reddish, but not too bright to be a dust. At the end I discovered that some dust areas are more blue than red and had to tweak the weights even more.

if ( 1.03f * pixel[ R ] >= pixel[ B ] // Allowing little blue tone
&& 1.25f * pixel[ R ] >= pixel[ G ] // Allowing some orange tone
&& pixel[ R ] > MIN_PIXEL_BRIGHTNESS_FOR_DUST // Avoid black color (and its noise)
&& pixelBrightness < MAX_PIXEL_BRIGHTNESS_FOR_DUST ) // Avoid white color
{
/// code for adding dust
}


Finally the image was parsed with a relatively satisfying result:

On the left is a small fraction of the Galaxy where I was testing the detection. You can see the white pixels hitting the blurred white spots.
On the right is a test of full galaxy - white pixels representing bright spots, red pixels tracking the dust in arms.

(Because of drawing performace only every 10th red dot is displayed)

detection.jpg
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!