How would I create a mask based on my tilemap

I am trying to add a paint splatter and can’t seem to figure out how I am going to programmatically create a mask for the sprites.

I was thinking maybe I could use the tilemap collider, but I can’t seem to get it to work.
I have this code but that’s it:

void FixedUpdate()
{
    transform.Translate(new Vector3(0, -0.25f, 0));
    if (transform.position.y < -10f)
        transform.Translate(new Vector3(0, -transform.position.y, 0));

    for (int x = -80; x < 80; x++)
    {
        // Cast a ray straight down.
        RaycastHit2D hit = Physics2D.Raycast(new Vector3(x/4, transform.position.y, transform.position.z), Vector3.forward, Mathf.Infinity, 1 << 16);

        // If it hits something...
        if (hit.collider != null)
        {
            Debug.Log(hit.collider);
        }
    }
}

Edit: The tilemaps are on layer 16

Edit 2: I have managed to solve this issue however I had to code my own solution to draw the tiles using prefabs with the Sprite Mask component on each

I have managed to solve this issue however I had to code my own solution to draw the tiles using prefabs with the Sprite Mask component on each

@BarnMS can you release the script on something like github???