Class EditingMaskStage<R extends bg.codexio.ai.openai.api.payload.images.request.ImageRequest,E extends RuntimeSelectionStage>
- All Implemented Interfaces:
IntermediateStage
A stage to specify the editable areas of the image.
You can choose to:
- Choose unmasked option, which will automatically make only the purely white areas of the image editable
- Upload a custom mask for the file with the transparent areas
- Specify the are that should be editable by color.
If you select this option, you'll have to choose
ColorDeviationlevel and provide a color in one of the following forms:- Decimal
- Hexadecimal
- RBG
- From the predefined colors selection in
PopularColor
-
Field Summary
Fields inherited from class bg.codexio.ai.openai.api.sdk.images.ImageConfigurationStage
builder, executor -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleanareColorsSimilar(int left, int right, double tolerance) protected BufferedImageasImage()protected booleanhasAlphaChannel(BufferedImage image) masked(int alphaZeroHex) masked(int red, int green, int blue) masked(int red, int green, int blue, ColorDeviation deviation) masked(int alphaZeroHex, ColorDeviation deviation) masked(PopularColor color) masked(PopularColor color, ColorDeviation deviation) masked(String colorHex, ColorDeviation deviation) protected voidresetImageWithAlpha(BufferedImage image, int alphaZeroHex, double deviation) This choice is almost the same as unmasked, but will handle more shades of white expanding the editable areas in comparison to the other optionunmasked()Skips the masking stage.protected BufferedImagewithAlphaChannel(BufferedImage image, int alphaZeroHex, double deviation)
-
Method Details
-
areColorsSimilar
protected static boolean areColorsSimilar(int left, int right, double tolerance) -
unmasked
Skips the masking stage.- Returns:
ChoicesStageto configure the choices count.
-
masked
- Parameters:
mask- file with the desired mask image. Sets a custom mask from the file provided.Important note: The mask must be a valid PNG file, less than 4MB, and have the same dimensions as the original image for editing. The fully transparent areas of the mask will be the areas of the original image that will be edited.
If any of those conditions is not followed, it will result in an error response.
- Returns:
ChoicesStageto configure the choices count.
-
masked
- Parameters:
alphaZeroHex- decimal value of the color that indicates the editable areasdeviation-ColorDeviationlevel of deviation - the similarity of the colors that should be marked as editable- Returns:
ChoicesStageto configure the choices count.
-
masked
- Parameters:
color-PopularColorchoice of color that indicates the editable areasdeviation-ColorDeviationlevel of deviation - the similarity of the colors that should be marked as editable- Returns:
ChoicesStageto configure the choices count.
-
masked
- Parameters:
color-PopularColorchoice of color that indicates the editable aresIn this case, the color deviation is automatically set to the lowest value, which means that only the specific color with no deviations will be marked for editing.
- Returns:
ChoicesStageto configure the choices count.
-
masked
- Parameters:
alphaZeroHex- decimal value of the color that indicates the editable areasIn this case, the color deviation is automatically set to the lowest value, which means that only the specific color with no deviations will be marked for editing.
- Returns:
ChoicesStageto configure the choices count.
-
masked
- Parameters:
red- the amount of red in RGB color scale for marking the editable areagreen- the amount of green in RGB color scale for marking the editable areablue- the amount of blue in RGB color scale for marking the editable areadeviation-ColorDeviationlevel of deviation - the similarity of the colors that should be marked as editable- Returns:
ChoicesStageto configure the choices count.
-
masked
- Parameters:
red- the amount of red in RGB color scale for marking the editable areagreen- the amount of green in RGB color scale for marking the editable areablue- the amount of blue in RGB color scale for marking the editable areaIn this case, the color deviation is automatically set to the lowest value, which means that only the specific color with no deviations will be marked for editing.
- Returns:
ChoicesStageto configure the choices count.
-
masked
- Parameters:
colorHex- hexadecimal value of the color that indicates the editable areasdeviation-ColorDeviationlevel of deviation - the similarity of the colors that should be marked as editable- Returns:
ChoicesStageto configure the choices count.
-
masked
- Parameters:
colorHex- hexadecimal value of the color that indicates the editable areasIn this case, the color deviation is automatically set to the lowest value, which means that only the specific color with no deviations will be marked for editing.
- Returns:
ChoicesStageto configure the choices count.
-
smallTransparency
This choice is almost the same as unmasked, but will handle more shades of white expanding the editable areas in comparison to the other option- Returns:
ChoicesStageto configure the choices count.
-
asImage
-
withAlphaChannel
-
hasAlphaChannel
-
resetImageWithAlpha
-