Mask mask = Mask.BandMathsType.create(maskName + bandName, null, imageWidth, imageHeight, "'" + bandName + "'", Color.white, 0.5); product.addMask(mask);
final String expression; if (overlayMask.getImageType() == Mask.BandMathsType.INSTANCE) { expression = Mask.BandMathsType.getExpression(overlayMask); } else if (overlayMask.getImageType() == Mask.RangeType.INSTANCE) { expression = Mask.RangeType.getExpression(overlayMask);
private void importMasksFromBmdx(File file) { try { final SAXBuilder saxBuilder = new SAXBuilder(); final Document document = saxBuilder.build(file); final Element rootElement = document.getRootElement(); @SuppressWarnings({"unchecked"}) final List<Element> children = rootElement.getChildren(DimapProductConstants.TAG_BITMASK_DEFINITION); final Product product = getMaskForm().getProduct(); for (Element element : children) { Mask mask = Mask.BandMathsType.createFromBitmaskDef(element, product.getSceneRasterWidth(), product.getSceneRasterHeight()); product.getMaskGroup().add(mask); } } catch (Exception e) { showErrorDialog(String.format("Failed to import mask(s): %s", e.getMessage())); } }
mask = Mask.BandMathsType.create("IDEPIX_INVALID", IDEPIX_INVALID_DESCR_TEXT, w, h, "pixel_classif_flags.IDEPIX_INVALID", getRandomColour(r), 0.5f); gaCloudProduct.getMaskGroup().add(index++, mask); mask = Mask.BandMathsType.create("IDEPIX_CLOUD", IDEPIX_CLOUD_DESCR_TEXT, w, h, "pixel_classif_flags.IDEPIX_CLOUD or pixel_classif_flags.IDEPIX_CLOUD_SURE or pixel_classif_flags.IDEPIX_CLOUD_AMBIGUOUS", new Color(178, 178, 0), 0.5f); gaCloudProduct.getMaskGroup().add(index++, mask); mask = Mask.BandMathsType.create("IDEPIX_CLOUD_AMBIGUOUS", IDEPIX_CLOUD_AMBIGUOUS_DESCR_TEXT, w, h, "pixel_classif_flags.IDEPIX_CLOUD_AMBIGUOUS", new Color(255, 219, 156), 0.5f); gaCloudProduct.getMaskGroup().add(index++, mask); mask = Mask.BandMathsType.create("IDEPIX_CLOUD_SURE", IDEPIX_CLOUD_SURE_DESCR_TEXT, w, h, "pixel_classif_flags.IDEPIX_CLOUD_SURE", new Color(224, 224, 30), 0.5f); gaCloudProduct.getMaskGroup().add(index++, mask); mask = Mask.BandMathsType.create("IDEPIX_CLOUD_BUFFER", IDEPIX_CLOUD_BUFFER_DESCR_TEXT, w, h, "pixel_classif_flags.IDEPIX_CLOUD_BUFFER", Color.red, 0.5f); gaCloudProduct.getMaskGroup().add(index++, mask); mask = Mask.BandMathsType.create("IDEPIX_CLOUD_SHADOW", IDEPIX_CLOUD_SHADOW_DESCR_TEXT, w, h, "pixel_classif_flags.IDEPIX_CLOUD_SHADOW", Color.cyan, 0.5f);
Mask mask0 = Mask.BandMathsType.create("MG2_Water_Mask_" + geoposition.id, "Water mask", width, height, Mask mask1 = Mask.BandMathsType.create("MG2_Cloud_Mask_All_Cloud_" + geoposition.id, "Result of a 'logical OR' for all the cloud masks", width, height, Mask mask2 = Mask.BandMathsType.create("MG2_Snow_Mask_" + geoposition.id, "Snow mask", width, height, Mask mask3 = Mask.BandMathsType.create("MG2_Shadow_Mask_Of_Cloud_" + geoposition.id, "Shadow masks of cloud", width, height, Mask mask4 = Mask.BandMathsType.create("MG2_Topographical_Shadows_Mask_" + geoposition.id, "Topographical shadows mask", width, height, Mask mask5 = Mask.BandMathsType.create("MG2_Hidden_Areas_Mask_" + geoposition.id, "Hidden areas mask", width, height, Mask mask6 = Mask.BandMathsType.create("MG2_Sun_Too_Low_Mask_" + geoposition.id, "Sun too low mask", width, height, Mask mask7 = Mask.BandMathsType.create("MG2_Tangent_Sun_Mask_" + geoposition.id,
Mask mask0 = Mask.BandMathsType.create("cloud_mask_all_" + geoposition.id, "Result of a 'logical OR' for all the cloud and shadow maks", width, height, Mask mask1 = Mask.BandMathsType.create("cloud_mask_all_cloud_" + geoposition.id, "Result of a 'logical OR' for all the cloud masks", width, height, Mask mask2 = Mask.BandMathsType.create("cloud_mask_refl_" + geoposition.id, "Cloud mask identified by a reflectance threshold", width, height, Mask mask3 = Mask.BandMathsType.create("cloud_mask_refl_var_" + geoposition.id, "Cloud mask identified by a threshold on reflectance variance", width, height, Mask mask4 = Mask.BandMathsType.create("cloud_mask_extension_" + geoposition.id, "Cloud mask identified by the extension of cloud masks", width, height, Mask mask5 = Mask.BandMathsType.create("cloud_mask_shadow_" + geoposition.id, "Shadow mask of clouds inside the image", width, height, Mask mask6 = Mask.BandMathsType.create("cloud_mask_sahdvar_" + geoposition.id, "Shadow mask of clouds outside the image", width, height, Mask mask7 = Mask.BandMathsType.create("cloud_mask_cirrus_" + geoposition.id,
Mask mask = Mask.BandMathsType.create(indexBandInformation.getPrefix() + indexName.toLowerCase(), description, dimension.width, dimension.height, String.format("%s.raw == %d", indexBandInformation.getPhysicalBand(), indexValue), color, 0.5);
Mask mask = Mask.BandMathsType.create("saturation_" + bandId, String.format("Saturation mask of band %s", bandId), width, height,
Mask mask = Mask.BandMathsType.create(String.format("detector_footprint-%s-%02d",formatBandNameTo3characters(orderedBandNames[i]),detector), "Detector footprint", width, height,
Mask.ImageType imageType = sourceMask.getImageType(); if (imageType.getName().equals(Mask.BandMathsType.TYPE_NAME)) { String expression = Mask.BandMathsType.getExpression(sourceMask); Mask targetMask = Mask.BandMathsType.create(sourceMask.getName(), sourceMask.getDescription(), targetProduct.getSceneRasterWidth(), targetProduct.getSceneRasterHeight(), expression,
targetBand.setSourceImage(srcBand.getSourceImage()); Mask mask = Mask.BandMathsType.create(maskName, "Interpolated AOT pixels mask", width, height,
Mask mask = Mask.BandMathsType.create(String.format("defective_%s",orderedBandNames[i]), "Detector footprint", width, height,
targetBand.setSourceImage(srcBand.getSourceImage()); Mask mask = Mask.BandMathsType.create(maskName, "Edge mask", width, height,
String expression = "B > " + (i / (colors.length - 1.0)); String name = "M_" + (product.getMaskGroup().getNodeCount() + 1); Mask mask = Mask.BandMathsType.create(name, expression, product.getSceneRasterWidth(), product.getSceneRasterHeight(), expression, colors[i], 1.0 - 1.0 / (1 + (i % 4))); product.getMaskGroup().add(mask);
setBands(); validPixelMask = Mask.BandMathsType.create("__valid_pixel_mask", null, getSourceProduct().getSceneRasterWidth(), getSourceProduct().getSceneRasterHeight(),
@Override protected void addMetadataMasks(Product product, SpotDimapMetadata componentMetadata) { logger.info("Create masks"); int noDataValue,saturatedValue; if ((noDataValue = componentMetadata.getNoDataValue()) >= 0) { product.getMaskGroup().add(Mask.BandMathsType.create(SpotConstants.NODATA_VALUE, SpotConstants.NODATA_VALUE, product.getSceneRasterWidth(), product.getSceneRasterHeight(), String.valueOf(noDataValue), componentMetadata.getNoDataColor(), 0.5)); } if ((saturatedValue = componentMetadata.getSaturatedPixelValue()) >= 0) { product.getMaskGroup().add(Mask.BandMathsType.create(SpotConstants.SATURATED_VALUE, SpotConstants.SATURATED_VALUE, product.getSceneRasterWidth(), product.getSceneRasterHeight(), String.valueOf(saturatedValue), componentMetadata.getSaturatedColor(), 0.5)); } } }
@Override protected void addMetadataMasks(Product product, DeimosMetadata componentMetadata) { logger.info("Create masks"); int noDataValue,saturatedValue; if ((noDataValue = componentMetadata.getNoDataValue()) >= 0) { product.getMaskGroup().add(Mask.BandMathsType.create(DeimosConstants.NODATA_VALUE, DeimosConstants.NODATA_VALUE, product.getSceneRasterWidth(), product.getSceneRasterHeight(), String.valueOf(noDataValue), componentMetadata.getNoDataColor(), 0.5)); } if ((saturatedValue = componentMetadata.getSaturatedPixelValue()) >= 0) { product.getMaskGroup().add(Mask.BandMathsType.create(DeimosConstants.SATURATED_VALUE, DeimosConstants.SATURATED_VALUE, product.getSceneRasterWidth(), product.getSceneRasterHeight(), String.valueOf(saturatedValue), componentMetadata.getSaturatedColor(), 0.5)); } }
/** * Creates and adds masks to the product, by using the given flag coding. Each added mask uses the width and the height of the product. * * @param product the product on which the masks are added * @param flagCoding for each flag of this flagCoding parameter, a new mask is added, with the same name as the flag * @return the list of all the masks added to the product */ List<Mask> createMasksFromFlagCodding(Product product, FlagCoding flagCoding) { String flagCodingName = flagCoding.getName(); ArrayList<Mask> masks = new ArrayList<Mask>(); final int width = product.getSceneRasterWidth(); final int height = product.getSceneRasterHeight(); for (String flagName : flagCoding.getFlagNames()) { MetadataAttribute flag = flagCoding.getFlag(flagName); masks.add(Mask.BandMathsType.create(flagName, flag.getDescription(), width, height, flagCodingName + "." + flagName, ColorIterator.next(), 0.5)); } return masks; }
private void addIndexMasks(Product product, List<BandInfo> bandInfoList, Map<S2SpatialResolution,Dimension> sceneDimensions) throws IOException { for (BandInfo bandInfo : bandInfoList) { if (bandInfo.getBandInformation() instanceof S2IndexBandInformation) { S2IndexBandInformation indexBandInformation = (S2IndexBandInformation) bandInfo.getBandInformation(); IndexCoding indexCoding = indexBandInformation.getIndexCoding(); product.getIndexCodingGroup().add(indexCoding); List<Color> colors = indexBandInformation.getColors(); Iterator<Color> colorIterator = colors.iterator(); for (String indexName : indexCoding.getIndexNames()) { int indexValue = indexCoding.getIndexValue(indexName); String description = indexCoding.getIndex(indexName).getDescription(); if (!colorIterator.hasNext()) { // we should never be here : programming error. throw new IOException(String.format("Unexpected error when creating index masks : colors list does not have the same size as index coding")); } Color color = colorIterator.next(); Mask mask = Mask.BandMathsType.create(indexBandInformation.getPrefix() + indexName.toLowerCase(), description, sceneDimensions.get(bandInfo.getBandInformation().getResolution()).width, sceneDimensions.get(bandInfo.getBandInformation().getResolution()).height, String.format("%s.raw == %d", indexBandInformation.getPhysicalBand(), indexValue), color, 0.5); product.addMask(mask); } } } }
private void addMasks(Product product, SpotDimapMetadata componentMetadata) { logger.info("Create masks"); int noDataValue,saturatedValue; if ((noDataValue = componentMetadata.getNoDataValue()) >= 0 && !product.getMaskGroup().contains(SpotConstants.NODATA_VALUE)) { product.getMaskGroup().add(Mask.BandMathsType.create(SpotConstants.NODATA_VALUE, SpotConstants.NODATA_VALUE, product.getSceneRasterWidth(), product.getSceneRasterHeight(), String.valueOf(noDataValue), componentMetadata.getNoDataColor(), 0.5)); } if ((saturatedValue = componentMetadata.getSaturatedPixelValue()) >= 0 && !product.getMaskGroup().contains(SpotConstants.SATURATED_VALUE)) { product.getMaskGroup().add(Mask.BandMathsType.create(SpotConstants.SATURATED_VALUE, SpotConstants.SATURATED_VALUE, product.getSceneRasterWidth(), product.getSceneRasterHeight(), String.valueOf(saturatedValue), componentMetadata.getSaturatedColor(), 0.5)); } } }