MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / sample_from_density_map

Function sample_from_density_map

utils/strand_util.py:539–549  ·  view source on GitHub ↗
(density_map, downsample_lvl=None)

Source from the content-addressed store, hash-verified

537#we randomly samples some indices from it considering the density as probability
538#return binary_map of B,1,H,W with some pixels on white where we should sample strands and some on black where there shouldn't be any strand
539def sample_from_density_map(density_map, downsample_lvl=None):
540 if downsample_lvl is not None:
541 density_map = torch.nn.functional.interpolate(density_map, scale_factor=1.0/downsample_lvl)
542
543 rand_map = torch.rand_like(density_map)
544
545 density_clamped= torch.clamp(density_map, 0.0, 1.0)
546
547 binary_map = (rand_map<=density_clamped).float()
548
549 return binary_map
550
551
552def sample_strands_from_scalp_with_density(scalp_texture, density_map, strand_codec, normalization_dict,

Calls

no outgoing calls

Tested by

no test coverage detected