I would like to assign a number identifier to the white parts of a black and white image or pattern, and store the number in a script (not to be printed on the image/screen). See example images in the attached, the top row are the images I would have in Filter Forge, either through an 'image' or 'color control' component. The bottom row shows the numbers that would be assigned.
Going from left to right, top to bottom, the number assigned would be consecutive for each white area. Can we identify the bounds of each white area in one go in FF? Or do I need to step through, slowly scanning - eg. The first pixel/area that is white would be assigned the Number 1, then I guess comparison of the next pixel/area (left/right/top/bottom) would need to check if there was black, and if not, assign that Number 1 as well; otherwise if there is black, skip to the next white pixel/area and assign that as Number 2, and so on.
With the resulting numbers in the script, I would then create values that I can use to make each white area a different color/pattern fill/input depending on the number.
Can Lua scripting be performed in FF for this outcome? If so, does anyone have a starting example script that I could base my script on, as I am a beginner?