Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find an algorithm for generating digital camouflage pattern? [closed]

Tags:

c#

algorithm

Here is a sample of what I'm looking to reproduce.

I thought about tiling an image but that would create a detectable pattern. I also thought about a random pattern using 4 or 5 colors but this is not a random pattern.

Thanks!

like image 456
DenaliHardtail Avatar asked Jun 16 '11 18:06

DenaliHardtail


2 Answers

The military uses a fractal pattern called MARPAT, which I understand is highly effective compared to other known camo patterns. However, they have patented it, and I'm not aware of any way to find out the specifics.

Your best bet is probably Perlin noise, though I'm not sure how effective it would be as actual camouflage if you printed it out and tried to hide with it. You should be able to generate something that looks a lot like military camouflage, which is probably what you're trying to do.

like image 56
Justin Morgan Avatar answered Sep 26 '22 21:09

Justin Morgan


What I would do:

  1. choose a few colors for your camo
  2. create a blank canvas
  3. seed a number of points using your colors (change random pixels to a random color)
  4. fill in the gaps using the algorithm below.

You want this to be random but you also want some clustering for those stripes/blobs in your example. So, by filling in the gaps from the seed points outwards, you can use the surrounding pixels to influence the color decision. If a pixel is surrounded by green, then it should be more likely to be green than yellow. So, for every pixel moving outwards from the seed points:

  • Consider your surrounding (8, 24, etc) pixels and use those to determine the chances for each color. Each color gets assigned a range of numbers between 0 and 1 (For example, green might be .23 - .57). The sum of the ranges should include all numbers between 0 and 1.
  • Use a random number generator to choose a number between 0 and 1. Whatever color range the number falls into is what color that pixel should be.
  • Find an adjacent blank pixel, repeat.

Totally untested, but it works in my head? Haha.

EDIT And if you'd like the larger boxes that digital camo actually has (as opposed to single pixels) group the pixels into groups of 9, 16, 25, 36, etc.

like image 34
Coeffect Avatar answered Sep 23 '22 21:09

Coeffect