Minimap autocorrection help

I’m trying to make a minimap renderer try to auto-correct spaces where the raycast fails to hit a part of terrain, so it gets a random of 4 or less pixels around it, depending whether or not the pixels around it, and fills it in.

When the minimap iterates over rows and columns, it stores data into a huge data table, with corresponding X and Y equaling the color. However, it DOESN’T store data for rays that don’t hit anything.

So, this auto-corrector is good for cases like these,

Problem is, cases with blank space, or blank space holes within the map, just malfunctions.
So, the help I need is,

How would I find if the blank space exists? Given that, the blank space is at least 2 pixels thick and can border, or partially border the map, depending on its location. Or, a hole within the map. I’d need an algorithm, pseudo-code, that puts all the candidate “blank space” into a table so it can have its own things done to it or whatnot. NOT the spaces missed from the raycasts missing through terrain.

How’s the data from this stored and how are you rendering it? Assuming there’s a 1:1 correspondence it’s dead simple to find a hole in the array.

As for filling the gaps, any procedural content-aware algorithm ought to work. I’ve been looking at the Wave Function Collapse algorithm recently, which you might find useful if you are pre-rendering the minimap.

It is a 1:1 correspondence. Table[X][Y]

The hole can be in any form, be it a circle, a donut hole shape; basically, its like in photo editing software the magic wand tool can select the whitespace. It’s like what I’m trying to do right now, except try to store it into a table. Problem is, I’m trying to know whether a relatively large whitespace can exist that certifies that it raycasted through intentionally when terrain didn’t exist, and try to get all holes, or the terrain empty border. Out of bounds terrain. Secondly, I don’t know the psuedocode for some sort of recursive function can try to grow outward to get all the white space.

The general algorithm is called a flood fill but which specific implementation you use will depend on a number of things.

Assuming the outer corners are always empty (that is, you are overscanning with your raycasts), you can do a floodfill search from any of the corners to find the “outer boundary” of the map.

Additionally, you could do a floodfill search from a known piece of map geometry to find all of it, and invert the results to get all the holes.