How to find a particular percentile value for an image


#1

I want to do thresholding for an image based on percentiles. So, I am interested in finding the 10th and 90th percentile values of an image. From image statistics, the 75th, 80th, 85th, 90th can be obtained.


#2

In the GUI there is no option for specifying different percentile values. There is operator from the command line. It called StatisticsOp.
With this one you can compute any percentile value.


#3

Now I remember, there is an option to get the percentile values in the GUI.
You can read the values from the plots. If you hover over the Percentile Plot you can see the values.


#4

Hi marpet,
it only displays the graph from that we can’t know the percentile values. My interest is to do thresholding based on less than 10th and greater than 90th percentile values. I am trying to do this in band math expression but not getting it. So can you guide me how to do that.


#5

Hi marpet,
I try to use the Statisticsop but the following error occured
gpt E:\PHD\Thesis\SARSoft\SNAP\S1_Chennai_TSA\XML\BandStat_Try.xml
INFO: org.esa.snap.python.gpf.PyOperatorSpi: Python operator ‘S2RutOp’ registered (Python module: ‘s2_rut’, class: ‘S2RutOp’, root: ‘C:\Users\SAIPLANNER\AppData\Roaming\SNAP\modules\org-esa-snap-snap-rut.jar’)
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
com.thoughtworks.xstream.converters.ConversionException: : unexpected character in markup . (position: END_TAG seen …\r\n <… @32:13) : : unexpected character in markup . (position: END_TAG seen …\r\n <… @32:13)
---- Debugging information ----
message : : unexpected character in markup . (position: END_TAG seen …\r\n <… @32:13)
cause-exception : com.thoughtworks.xstream.io.StreamException
cause-message : : unexpected character in markup . (position: END_TAG seen …\r\n <… @32:13)
class : com.bc.ceres.binding.dom.DomElement
required-type : com.bc.ceres.binding.dom.DomElement
converter-type : com.bc.ceres.binding.dom.DomElementXStreamConverter
path : /graph/node[2]/parameters/bandConfigurations
line number : 32
class[1] : org.esa.snap.core.gpf.graph.Node
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2] : org.esa.snap.core.gpf.graph.Graph
version : 1.4.8

    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:383)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1206)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1190)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1061)
    at org.esa.snap.core.gpf.graph.GraphIO.read(GraphIO.java:83)
    at org.esa.snap.core.gpf.main.DefaultCommandLineContext.readGraph(DefaultCommandLineContext.java:75)
    at org.esa.snap.core.gpf.main.CommandLineTool.readGraph(CommandLineTool.java:530)
    at org.esa.snap.core.gpf.main.CommandLineTool.runGraph(CommandLineTool.java:342)
    at org.esa.snap.core.gpf.main.CommandLineTool.runGraphOrOperator(CommandLineTool.java:287)
    at org.esa.snap.core.gpf.main.CommandLineTool.run(CommandLineTool.java:188)
    at org.esa.snap.core.gpf.main.CommandLineTool.run(CommandLineTool.java:121)
    at org.esa.snap.core.gpf.main.GPT.run(GPT.java:54)
    at org.esa.snap.core.gpf.main.GPT.main(GPT.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.esa.snap.runtime.Launcher.lambda$run$14(Launcher.java:55)
    at org.esa.snap.runtime.Engine.runClientCode(Engine.java:189)
    at org.esa.snap.runtime.Launcher.run(Launcher.java:51)
    at org.esa.snap.runtime.Launcher.main(Launcher.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:62)
    at com.exe4j.runtime.WinLauncher.main(WinLauncher.java:101)
    at com.install4j.runtime.launcher.WinLauncher.main(WinLauncher.java:16)

Caused by: com.thoughtworks.xstream.io.StreamException: : unexpected character in markup . (position: END_TAG seen …\r\n <… @32:13)
at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:124)
at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:148)
at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:135)
at com.thoughtworks.xstream.io.xml.AbstractPullReader.hasMoreChildren(AbstractPullReader.java:87)
at com.thoughtworks.xstream.io.ReaderWrapper.hasMoreChildren(ReaderWrapper.java:32)
at com.thoughtworks.xstream.io.copy.HierarchicalStreamCopier.copy(HierarchicalStreamCopier.java:45)
at com.thoughtworks.xstream.io.copy.HierarchicalStreamCopier.copy(HierarchicalStreamCopier.java:47)
at com.bc.ceres.binding.dom.DomElementXStreamConverter.unmarshal(DomElementXStreamConverter.java:52)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
… 44 more
Caused by: org.xmlpull.v1.XmlPullParserException: unexpected character in markup . (position: END_TAG seen …\r\n <… @32:13)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1261)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:109)
… 52 more

Error: : unexpected character in markup . (position: END_TAG seen …\r\n <… @32:13) : : unexpected character in markup . (position: END_TAG seen …\r\n <… @32:13)
---- Debugging information ----
message : : unexpected character in markup . (position: END_TAG seen …\r\n <… @32:13)
cause-exception : com.thoughtworks.xstream.io.StreamException
cause-message : : unexpected character in markup . (position: END_TAG seen …\r\n <… @32:13)
class : com.bc.ceres.binding.dom.DomElement
required-type : com.bc.ceres.binding.dom.DomElement
converter-type : com.bc.ceres.binding.dom.DomElementXStreamConverter
path : /graph/node[2]/parameters/bandConfigurations
line number : 32
class[1] : org.esa.snap.core.gpf.graph.Node
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2] : org.esa.snap.core.gpf.graph.Graph
version : 1.4.8<a class=“attachment”

Here is the XML file:
href="/uploads/default/original/2X/8/8f67b5a221953d16cc084dcacca9ca98b7936f24.xml">BandStat_Try.xml (1.7 KB)


#6

BandStat_Try.xml (1.7 KB)


#7

You need to remove “<…/>” in line 32.

In Band Math it is not possible to compute these values, because it is pixel based.

But the percentile graph shows you the percentile for each p* between 1 and 100.
But I understand that this is not what you want.