Packages

 

com.aspose.imaging.masking.options

Class DetectedObjectType

  • java.lang.Object
    • com.aspose.ms.System.ValueType<com.aspose.ms.System.Enum>
      • com.aspose.ms.System.Enum
        • com.aspose.imaging.masking.options.DetectedObjectType


  • public final class DetectedObjectType
    extends com.aspose.ms.System.Enum

    The detected object types enumeration.

    Code example:

    Saving image masking result with feathering based on image size. Image masking is performed using auto calculated default strokes. Additionally the data of the two assumed objects is also specified in the AssumedObjects property of the AutoMaskingGraphCutOptions.


    List<AssumedObjectData> assumedObjects = new LinkedList<AssumedObjectData>();
    assumedObjects.add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
    assumedObjects.add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));
    
    MaskingResult[] results;
    try (RasterImage image = (RasterImage)Image.load("input.jpg"))
    {
        try (PngOptions pngOptions = new PngOptions())
        {
            pngOptions.setColorType(PngColorType.TruecolorWithAlpha);
            pngOptions.setSource(new FileCreateSource("tempFile"));
    
            AutoMaskingGraphCutOptions options = new AutoMaskingGraphCutOptions();
            options.setAssumedObjects(assumedObjects);
            options.setCalculateDefaultStrokes(true);
            options.setFeatheringRadius((Math.max(image.getWidth(), image.getHeight()) / 500) + 1);
            options.setMethod(SegmentationMethod.GraphCut);
            options.setDecompose(false);
            options.setExportOptions(pngOptions);
            options.setBackgroundReplacementColor(Color.getTransparent());
    
            results = new ImageMasking(image).decompose(options);
        }
    }
    
    try (RasterImage resultImage = (RasterImage)results[1].getImage())
    {
        PngOptions pngOptions = new PngOptions();
        pngOptions.setColorType(PngColorType.TruecolorWithAlpha);
        resultImage.save("output.png", pngOptions);
    }
    
    // release resources
    for (MaskingResult res : results)
    {
        res.close();
    }
                
    

    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.aspose.ms.System.Enum

        com.aspose.ms.System.Enum.AbstractEnum, com.aspose.ms.System.Enum.FlaggedEnum, com.aspose.ms.System.Enum.ObjectEnum, com.aspose.ms.System.Enum.SimpleEnum
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int Human
      The human object type.
      static int Other
      Other object type.
      • Fields inherited from class com.aspose.ms.System.Enum

        EnumSeparatorCharArray
    • Method Summary

      • Methods inherited from class com.aspose.ms.System.Enum

        Clone, CloneTo, format, format, get_Caption, get_Value, getName, getName, getNames, getNames, getNames, getUnderlyingType, getUnderlyingType, getValue, getValues, getValues, getValues, isDefined, isDefined, isDefined, isDefined, parse, parse, parse, parse, register, toObject, toString