OOF2: The Manual

Name

OOF.Image.AutoGroup — Create a pixel group for each color in the image.

Synopsis

OOF.Image.AutoGroup(image,name_template)

Details

  • Parent Menu: OOF.Image
  • Callback: function createPixelGroups in module ooflib.image.IO.imagemenu
  • Parameters:

    image
    Type: The path to an existing Image object.
    name_template
    Name for the pixel groups. %n is replaced by a number, %c by the pixel color. Type: A character string.

Description

If a Microstructure is being built from an Image which has a one-to-one correspondence between pixel color and Material, then the most convenient way to assign Materials to pixels is to automatically create a PixelGroup for each color, and then to assign Materials to the pixels in each pixel group. The AutoGroup command performs the first part of this process, creating pixel groups for each color of pixel in the given Image.

The name_template parameter specifies how the names for the automatically created groups will be generated. It should be a string containing either %c or %n or both. When naming a group, %c will be replaced by the color of the pixels in the group, and %n will be replaced by an integer. The colors are written in the slightly uncomfortable but compact form #RRGGBB, where RR, GG, and BB are the hexadecimal values of the 8-bit RGB color channels. It may be advisable to manually rename the groups.

The name_template parameter is new in OOF2 version 2.0.4. To reproduce the pre-2.0.4 behavior, set name_template to %c.

[Caution] Caution

Images produced by drawing programs that use antialiasing to smooth lines are generally not suitable candidates for AutoGroup. Even if an antialiased image appears to contain only a few colors, it will generally have many slightly different colors at the borders between regions, and AutoGrouping will create a large number of groups. On antialiased images it's best to select pixels with, for example, OOF.PixelSelection.Color_Range and assign them to a group manually with OOF.PixelGroup.AddSelection.