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); } } } }
protected List<Mask> createMasksFromFlagCodding(Product product, FlagCoding flagCoding) { String flagCodingName = flagCoding.getName(); ArrayList<Mask> masks = new ArrayList<>(); 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; }
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 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("saturation_" + bandId, String.format("Saturation mask of band %s", bandId), width, height,
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,
Mask mask = Mask.BandMathsType.create(String.format("detector_footprint-%s-%02d",formatBandNameTo3characters(orderedBandNames[i]),detector), "Detector footprint", width, height,
targetBand.setSourceImage(srcBand.getSourceImage()); Mask mask = Mask.BandMathsType.create(maskName, "Interpolated AOT pixels mask", width, height,
targetBand.setSourceImage(srcBand.getSourceImage()); Mask mask = Mask.BandMathsType.create(maskName, "Edge mask", width, height,
Mask mask = Mask.BandMathsType.create(String.format("defective_%s",orderedBandNames[i]), "Detector footprint", 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 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)); } } }
public static void createFlagMasks(Product targetProduct) { Guardian.assertNotNull("targetProduct", targetProduct); int w = targetProduct.getSceneRasterWidth(); int h = targetProduct.getSceneRasterHeight(); MyMaskColor mColor = new MyMaskColor(); ProductNodeGroup<Mask> tarMG = targetProduct.getMaskGroup(); ProductNodeGroup<FlagCoding> tarFCG = targetProduct.getFlagCodingGroup(); for (int node=0; node<tarFCG.getNodeCount(); node++){ FlagCoding fc = tarFCG.get(node); for (int i=0; i<fc.getNumAttributes(); i++){ MetadataAttribute f = fc.getAttributeAt(i); String expr = fc.getName() + "." + f.getName(); Mask m = Mask.BandMathsType.create(f.getName(), f.getDescription(), w, h, expr, mColor.next(), 0.5); tarMG.add(m); } } }
private void addMasks(Product target, ImageMetadata metadata) { ProductNodeGroup<Mask> maskGroup = target.getMaskGroup(); if (!maskGroup.contains(Spot6Constants.NODATA)) { int noDataValue = metadata.getNoDataValue(); maskGroup.add(Mask.BandMathsType.create(Spot6Constants.NODATA, Spot6Constants.NODATA, target.getSceneRasterWidth(), target.getSceneRasterHeight(), String.valueOf(noDataValue), Color.BLACK, 0.5)); } if (!maskGroup.contains(Spot6Constants.SATURATED)) { int saturatedValue = metadata.getSaturatedValue(); maskGroup.add(Mask.BandMathsType.create(Spot6Constants.SATURATED, Spot6Constants.SATURATED, target.getSceneRasterWidth(), target.getSceneRasterHeight(), String.valueOf(saturatedValue), Color.ORANGE, 0.5)); } }
private void addMasks(Product target, ImageMetadata metadata) { ProductNodeGroup<Mask> maskGroup = target.getMaskGroup(); if (!maskGroup.contains(Constants.NODATA)) { int noDataValue = metadata.getNoDataValue(); maskGroup.add(Mask.BandMathsType.create(Constants.NODATA, Constants.NODATA, target.getSceneRasterWidth(), target.getSceneRasterHeight(), String.valueOf(noDataValue), Color.BLACK, 0.5)); } if (!maskGroup.contains(Constants.SATURATED)) { int saturatedValue = metadata.getSaturatedValue(); maskGroup.add(Mask.BandMathsType.create(Constants.SATURATED, Constants.SATURATED, target.getSceneRasterWidth(), target.getSceneRasterHeight(), String.valueOf(saturatedValue), Color.ORANGE, 0.5)); } }
private Mask addMask(Product product, RasterDataNode raster, String expression) { Mask mask = Mask.BandMathsType.create(maskName, maskDescription, raster.getRasterWidth(), raster.getRasterHeight(), expression, maskColor, 0.5); product.addMask(mask); ProductUtils.copyImageGeometry(raster, mask, false); return mask; }