Class EditingMaskStage<R extends bg.codexio.ai.openai.api.payload.images.request.ImageRequest,E extends RuntimeSelectionStage>
- java.lang.Object
-
- bg.codexio.ai.openai.api.sdk.images.ImageConfigurationStage<R>
-
- bg.codexio.ai.openai.api.sdk.images.EditingMaskStage<R,E>
-
- All Implemented Interfaces:
IntermediateStage
public class EditingMaskStage<R extends bg.codexio.ai.openai.api.payload.images.request.ImageRequest,E extends RuntimeSelectionStage> extends ImageConfigurationStage<R> implements 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static booleanareColorsSimilar(int left, int right, double tolerance)protected BufferedImageasImage()protected booleanhasAlphaChannel(BufferedImage image)ChoicesStage<R,E>masked(int alphaZeroHex)ChoicesStage<R,E>masked(int red, int green, int blue)ChoicesStage<R,E>masked(int red, int green, int blue, ColorDeviation deviation)ChoicesStage<R,E>masked(int alphaZeroHex, ColorDeviation deviation)ChoicesStage<R,E>masked(PopularColor color)ChoicesStage<R,E>masked(PopularColor color, ColorDeviation deviation)ChoicesStage<R,E>masked(File mask)ChoicesStage<R,E>masked(String colorHex)ChoicesStage<R,E>masked(String colorHex, ColorDeviation deviation)protected voidresetImageWithAlpha(BufferedImage image, int alphaZeroHex, double deviation)ChoicesStage<R,E>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 optionChoicesStage<R,E>unmasked()Skips the masking stage.protected BufferedImagewithAlphaChannel(BufferedImage image, int alphaZeroHex, double deviation)
-
-
-
Method Detail
-
areColorsSimilar
protected static boolean areColorsSimilar(int left, int right, double tolerance)
-
unmasked
public ChoicesStage<R,E> unmasked()
Skips the masking stage.- Returns:
ChoicesStageto configure the choices count.
-
masked
public ChoicesStage<R,E> masked(File mask)
- 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
public ChoicesStage<R,E> masked(int alphaZeroHex, ColorDeviation deviation)
- 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
public ChoicesStage<R,E> masked(PopularColor color, ColorDeviation deviation)
- 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
public ChoicesStage<R,E> masked(PopularColor color)
- 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
public ChoicesStage<R,E> masked(int alphaZeroHex)
- 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
public ChoicesStage<R,E> masked(int red, int green, int blue, ColorDeviation deviation)
- 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
public ChoicesStage<R,E> masked(int red, int green, int blue)
- 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
public ChoicesStage<R,E> masked(String colorHex, ColorDeviation deviation)
- 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
public ChoicesStage<R,E> masked(String colorHex)
- 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
public ChoicesStage<R,E> 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
protected BufferedImage asImage()
-
withAlphaChannel
protected BufferedImage withAlphaChannel(BufferedImage image, int alphaZeroHex, double deviation)
-
hasAlphaChannel
protected boolean hasAlphaChannel(BufferedImage image)
-
resetImageWithAlpha
protected void resetImageWithAlpha(BufferedImage image, int alphaZeroHex, double deviation)
-
-