Discussion:
[otb-users] BandmathX Sum of all bands
remicres
2018-06-07 09:57:34 UTC
Permalink
...or maybe "sizeof(im1')-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
My bad, I thought that you wanted the sum of positive components.
To count only the number of positive component you can use something like
this "54-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
Dear remicres,
I have just tested your expression on a 54 channel image. However the
result.tif is not giving me pixels values between (0-54) but values up to
174600.
Any ideas?
Oliver
You can also do it with BandMathX with the expression
"0.5*(im1+vabs(im1))*ones(sizeof(im1'),1)"
Got it . Needed to use " instead of ' to state the -exp to get it run.
Thanks a lot!!!
Not sure what I am doing wrong.
All it does is to write the error message into a file
Message: Unexpected token "'(im1b1 " found at position 0.
Try without sum : "(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 >
0) + (im1b5 > 0)"
Victor Poughon
*Envoyé :* lundi 4 juin 2018 12:20
*Objet :* Re: [otb-users] BandmathX Sum of all bands
Thanks Victor for you fast answer,
otbcli_BandMath -il InIMAGE.img -out OutIMAGEtest.img -exp 'sum((im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 > 0) + (im1b5 > 0))'
is not working and would not give me the number of bands with values >0 but a sum of pixel values, right?
Can I put the exp to 'sum((im1b1/im1b1 > 0) + (im1b2/im1b2 > 0) .....
Since you have a lot of bands, writing the exp by hand will be a very
ugly
 but it should work. You can make a quick python script to generate
the exp.
print(" + ".join(["(im1b" + str(i) + " > 0)" for i in range(1,
61)]))
(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 > 0) + (im1b5 > 0) + (im1b6 > 0) + (im1b7 > 0) + (im1b8 > 0) + (im1b9 > 0) + (im1b10 > 0) + (im1b11 > 0) + (im1b12 > 0) + (im1b13 > 0) + (im1b14 > 0) + (im1b15 > 0) + (im1b16 > 0) + (im1b17 > 0) + (im1b18 > 0) + (im1b19 > 0) + (im1b20 > 0) + (im1b21 > 0) + (im1b22 > 0) + (im1b23 > 0) + (im1b24 > 0) + (im1b25 > 0) + (im1b26 > 0) + (im1b27 > 0) + (im1b28 > 0) + (im1b29 > 0) + (im1b30 > 0) + (im1b31 > 0) + (im1b32 > 0) + (im1b33 > 0) + (im1b34 > 0) + (im1b35 > 0) + (im1b36 > 0) + (im1b37 > 0) + (im1b38 > 0) + (im1b39 > 0) + (im1b40 > 0) + (im1b41 > 0) + (im1b42 > 0) + (im1b43 > 0) + (im1b44 > 0) + (im1b45 > 0) + (im1b46 > 0) + (im1b47 > 0) + (im1b48 > 0) + (im1b49 > 0) + (im1b50 > 0) + (im1b51 > 0) + (im1b52 > 0) + (im1b53 > 0) + (im1b54 > 0) + (im1b55 > 0) + (im1b56 > 0) + (im1b57 > 0) + (im1b58 > 0) + (im1b59 > 0) + (im1b60 > 0)
Victor Poughon
*Envoyé :* lundi 4 juin 2018 11:08
*Objet :* [otb-users] BandmathX Sum of all bands
Dear all,
being new to OTB, my question might be trivial, so apologies if that
is the case.
What I would like to do with otbcli_BandMath is to calculate an image
that gives the sum of all bands representing values >0.
I have an image with nBands (in my test case n=60, but could be more
or less). Each pixel has thus a maximum of 60 values (some bands have
no-data, represented as -1 values).
What I would like to get is an output image, where each pixel value
gives me the amount of bands with values >0 per pixel from the inout image.
I don't know how to set the -exp
Tried with
- otbcli_BandMath -il
G:\PROJEKTE\2518_BfN_Grassland\04_Arbeitsdokumente\test_landsat_path\mask_194_24\layerstack_test_194_24_nodata_clip15.img
-out test.img -exp 'sum(im1/im1)'
but received
itk::ExceptionObject (0000008641989700)
Location: "unknown"
C:\dashboard\otb\src\Modules\Filtering\MathParser\src\otbParser.cxx
Line: 170
Message: Unexpected token "'sum(im1/im1)' " found at position 0.
Formula: 'sum(im1/im1)'
oken: 'sum(im1/im1)'
Position: 0
So I guess my -exp is wrong.
Thanks
Oliver
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/optout.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/optout.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'O Buck' via otb-users
2018-06-07 10:27:39 UTC
Permalink
Great, worked like a charm!
Post by remicres
...or maybe "sizeof(im1')-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
My bad, I thought that you wanted the sum of positive components.
To count only the number of positive component you can use something like
this "54-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
Dear remicres,
I have just tested your expression on a 54 channel image. However the
result.tif is not giving me pixels values between (0-54) but values up to
174600.
Any ideas?
Oliver
You can also do it with BandMathX with the expression
"0.5*(im1+vabs(im1))*ones(sizeof(im1'),1)"
Got it . Needed to use " instead of ' to state the -exp to get it run.
Thanks a lot!!!
Not sure what I am doing wrong.
All it does is to write the error message into a file
Message: Unexpected token "'(im1b1 " found at position 0.
Try without sum : "(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4
0) + (im1b5 > 0)"
Victor Poughon
*Envoyé :* lundi 4 juin 2018 12:20
*Objet :* Re: [otb-users] BandmathX Sum of all bands
Thanks Victor for you fast answer,
otbcli_BandMath -il InIMAGE.img -out OutIMAGEtest.img -exp 'sum((im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 > 0) + (im1b5 > 0))'
is not working and would not give me the number of bands with values >0 but a sum of pixel values, right?
Can I put the exp to 'sum((im1b1/im1b1 > 0) + (im1b2/im1b2 > 0) .....
Since you have a lot of bands, writing the exp by hand will be a
very ugly
 but it should work. You can make a quick python script to
generate the exp.
print(" + ".join(["(im1b" + str(i) + " > 0)" for i in range(1,
61)]))
(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 > 0) + (im1b5 > 0) + (im1b6 > 0) + (im1b7 > 0) + (im1b8 > 0) + (im1b9 > 0) + (im1b10 > 0) + (im1b11 > 0) + (im1b12 > 0) + (im1b13 > 0) + (im1b14 > 0) + (im1b15 > 0) + (im1b16 > 0) + (im1b17 > 0) + (im1b18 > 0) + (im1b19 > 0) + (im1b20 > 0) + (im1b21 > 0) + (im1b22 > 0) + (im1b23 > 0) + (im1b24 > 0) + (im1b25 > 0) + (im1b26 > 0) + (im1b27 > 0) + (im1b28 > 0) + (im1b29 > 0) + (im1b30 > 0) + (im1b31 > 0) + (im1b32 > 0) + (im1b33 > 0) + (im1b34 > 0) + (im1b35 > 0) + (im1b36 > 0) + (im1b37 > 0) + (im1b38 > 0) + (im1b39 > 0) + (im1b40 > 0) + (im1b41 > 0) + (im1b42 > 0) + (im1b43 > 0) + (im1b44 > 0) + (im1b45 > 0) + (im1b46 > 0) + (im1b47 > 0) + (im1b48 > 0) + (im1b49 > 0) + (im1b50 > 0) + (im1b51 > 0) + (im1b52 > 0) + (im1b53 > 0) + (im1b54 > 0) + (im1b55 > 0) + (im1b56 > 0) + (im1b57 > 0) + (im1b58 > 0) + (im1b59 > 0) + (im1b60 > 0)
Victor Poughon
*Envoyé :* lundi 4 juin 2018 11:08
*Objet :* [otb-users] BandmathX Sum of all bands
Dear all,
being new to OTB, my question might be trivial, so apologies if that
is the case.
What I would like to do with otbcli_BandMath is to calculate an
image that gives the sum of all bands representing values >0.
I have an image with nBands (in my test case n=60, but could be more
or less). Each pixel has thus a maximum of 60 values (some bands have
no-data, represented as -1 values).
What I would like to get is an output image, where each pixel value
gives me the amount of bands with values >0 per pixel from the inout image.
I don't know how to set the -exp
Tried with
- otbcli_BandMath -il
G:\PROJEKTE\2518_BfN_Grassland\04_Arbeitsdokumente\test_landsat_path\mask_194_24\layerstack_test_194_24_nodata_clip15.img
-out test.img -exp 'sum(im1/im1)'
but received
itk::ExceptionObject (0000008641989700)
Location: "unknown"
C:\dashboard\otb\src\Modules\Filtering\MathParser\src\otbParser.cxx
Line: 170
Message: Unexpected token "'sum(im1/im1)' " found at position 0.
Formula: 'sum(im1/im1)'
oken: 'sum(im1/im1)'
Position: 0
So I guess my -exp is wrong.
Thanks
Oliver
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/optout.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/optout.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'O Buck' via otb-users
2018-09-13 08:26:39 UTC
Permalink
How would I could the number "0" components?

Regards
Oliver
Post by remicres
...or maybe "sizeof(im1')-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
My bad, I thought that you wanted the sum of positive components.
To count only the number of positive component you can use something like
this "54-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
Dear remicres,
I have just tested your expression on a 54 channel image. However the
result.tif is not giving me pixels values between (0-54) but values up to
174600.
Any ideas?
Oliver
You can also do it with BandMathX with the expression
"0.5*(im1+vabs(im1))*ones(sizeof(im1'),1)"
Got it . Needed to use " instead of ' to state the -exp to get it run.
Thanks a lot!!!
Not sure what I am doing wrong.
All it does is to write the error message into a file
Message: Unexpected token "'(im1b1 " found at position 0.
Try without sum : "(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4
0) + (im1b5 > 0)"
Victor Poughon
*Envoyé :* lundi 4 juin 2018 12:20
*Objet :* Re: [otb-users] BandmathX Sum of all bands
Thanks Victor for you fast answer,
otbcli_BandMath -il InIMAGE.img -out OutIMAGEtest.img -exp 'sum((im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 > 0) + (im1b5 > 0))'
is not working and would not give me the number of bands with values >0 but a sum of pixel values, right?
Can I put the exp to 'sum((im1b1/im1b1 > 0) + (im1b2/im1b2 > 0) .....
Since you have a lot of bands, writing the exp by hand will be a
very ugly
 but it should work. You can make a quick python script to
generate the exp.
print(" + ".join(["(im1b" + str(i) + " > 0)" for i in range(1,
61)]))
(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 > 0) + (im1b5 > 0) + (im1b6 > 0) + (im1b7 > 0) + (im1b8 > 0) + (im1b9 > 0) + (im1b10 > 0) + (im1b11 > 0) + (im1b12 > 0) + (im1b13 > 0) + (im1b14 > 0) + (im1b15 > 0) + (im1b16 > 0) + (im1b17 > 0) + (im1b18 > 0) + (im1b19 > 0) + (im1b20 > 0) + (im1b21 > 0) + (im1b22 > 0) + (im1b23 > 0) + (im1b24 > 0) + (im1b25 > 0) + (im1b26 > 0) + (im1b27 > 0) + (im1b28 > 0) + (im1b29 > 0) + (im1b30 > 0) + (im1b31 > 0) + (im1b32 > 0) + (im1b33 > 0) + (im1b34 > 0) + (im1b35 > 0) + (im1b36 > 0) + (im1b37 > 0) + (im1b38 > 0) + (im1b39 > 0) + (im1b40 > 0) + (im1b41 > 0) + (im1b42 > 0) + (im1b43 > 0) + (im1b44 > 0) + (im1b45 > 0) + (im1b46 > 0) + (im1b47 > 0) + (im1b48 > 0) + (im1b49 > 0) + (im1b50 > 0) + (im1b51 > 0) + (im1b52 > 0) + (im1b53 > 0) + (im1b54 > 0) + (im1b55 > 0) + (im1b56 > 0) + (im1b57 > 0) + (im1b58 > 0) + (im1b59 > 0) + (im1b60 > 0)
Victor Poughon
*Envoyé :* lundi 4 juin 2018 11:08
*Objet :* [otb-users] BandmathX Sum of all bands
Dear all,
being new to OTB, my question might be trivial, so apologies if that
is the case.
What I would like to do with otbcli_BandMath is to calculate an
image that gives the sum of all bands representing values >0.
I have an image with nBands (in my test case n=60, but could be more
or less). Each pixel has thus a maximum of 60 values (some bands have
no-data, represented as -1 values).
What I would like to get is an output image, where each pixel value
gives me the amount of bands with values >0 per pixel from the inout image.
I don't know how to set the -exp
Tried with
- otbcli_BandMath -il
G:\PROJEKTE\2518_BfN_Grassland\04_Arbeitsdokumente\test_landsat_path\mask_194_24\layerstack_test_194_24_nodata_clip15.img
-out test.img -exp 'sum(im1/im1)'
but received
itk::ExceptionObject (0000008641989700)
Location: "unknown"
C:\dashboard\otb\src\Modules\Filtering\MathParser\src\otbParser.cxx
Line: 170
Message: Unexpected token "'sum(im1/im1)' " found at position 0.
Formula: 'sum(im1/im1)'
oken: 'sum(im1/im1)'
Position: 0
So I guess my -exp is wrong.
Thanks
Oliver
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/optout.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/optout.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'O Buck' via otb-users
2018-09-13 08:28:28 UTC
Permalink
Dear Remi,

How would I calculate the number of "0" components, i.e. the number of
bands where the pixel value is "0"?

Struggling to understand the muparser logic ;)

oliver
Post by remicres
...or maybe "sizeof(im1')-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
My bad, I thought that you wanted the sum of positive components.
To count only the number of positive component you can use something like
this "54-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
Dear remicres,
I have just tested your expression on a 54 channel image. However the
result.tif is not giving me pixels values between (0-54) but values up to
174600.
Any ideas?
Oliver
You can also do it with BandMathX with the expression
"0.5*(im1+vabs(im1))*ones(sizeof(im1'),1)"
Got it . Needed to use " instead of ' to state the -exp to get it run.
Thanks a lot!!!
Not sure what I am doing wrong.
All it does is to write the error message into a file
Message: Unexpected token "'(im1b1 " found at position 0.
Try without sum : "(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4
0) + (im1b5 > 0)"
Victor Poughon
*Envoyé :* lundi 4 juin 2018 12:20
*Objet :* Re: [otb-users] BandmathX Sum of all bands
Thanks Victor for you fast answer,
otbcli_BandMath -il InIMAGE.img -out OutIMAGEtest.img -exp 'sum((im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 > 0) + (im1b5 > 0))'
is not working and would not give me the number of bands with values >0 but a sum of pixel values, right?
Can I put the exp to 'sum((im1b1/im1b1 > 0) + (im1b2/im1b2 > 0) .....
Since you have a lot of bands, writing the exp by hand will be a
very ugly
 but it should work. You can make a quick python script to
generate the exp.
print(" + ".join(["(im1b" + str(i) + " > 0)" for i in range(1,
61)]))
(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 > 0) + (im1b5 > 0) + (im1b6 > 0) + (im1b7 > 0) + (im1b8 > 0) + (im1b9 > 0) + (im1b10 > 0) + (im1b11 > 0) + (im1b12 > 0) + (im1b13 > 0) + (im1b14 > 0) + (im1b15 > 0) + (im1b16 > 0) + (im1b17 > 0) + (im1b18 > 0) + (im1b19 > 0) + (im1b20 > 0) + (im1b21 > 0) + (im1b22 > 0) + (im1b23 > 0) + (im1b24 > 0) + (im1b25 > 0) + (im1b26 > 0) + (im1b27 > 0) + (im1b28 > 0) + (im1b29 > 0) + (im1b30 > 0) + (im1b31 > 0) + (im1b32 > 0) + (im1b33 > 0) + (im1b34 > 0) + (im1b35 > 0) + (im1b36 > 0) + (im1b37 > 0) + (im1b38 > 0) + (im1b39 > 0) + (im1b40 > 0) + (im1b41 > 0) + (im1b42 > 0) + (im1b43 > 0) + (im1b44 > 0) + (im1b45 > 0) + (im1b46 > 0) + (im1b47 > 0) + (im1b48 > 0) + (im1b49 > 0) + (im1b50 > 0) + (im1b51 > 0) + (im1b52 > 0) + (im1b53 > 0) + (im1b54 > 0) + (im1b55 > 0) + (im1b56 > 0) + (im1b57 > 0) + (im1b58 > 0) + (im1b59 > 0) + (im1b60 > 0)
Victor Poughon
*Envoyé :* lundi 4 juin 2018 11:08
*Objet :* [otb-users] BandmathX Sum of all bands
Dear all,
being new to OTB, my question might be trivial, so apologies if that
is the case.
What I would like to do with otbcli_BandMath is to calculate an
image that gives the sum of all bands representing values >0.
I have an image with nBands (in my test case n=60, but could be more
or less). Each pixel has thus a maximum of 60 values (some bands have
no-data, represented as -1 values).
What I would like to get is an output image, where each pixel value
gives me the amount of bands with values >0 per pixel from the inout image.
I don't know how to set the -exp
Tried with
- otbcli_BandMath -il
G:\PROJEKTE\2518_BfN_Grassland\04_Arbeitsdokumente\test_landsat_path\mask_194_24\layerstack_test_194_24_nodata_clip15.img
-out test.img -exp 'sum(im1/im1)'
but received
itk::ExceptionObject (0000008641989700)
Location: "unknown"
C:\dashboard\otb\src\Modules\Filtering\MathParser\src\otbParser.cxx
Line: 170
Message: Unexpected token "'sum(im1/im1)' " found at position 0.
Formula: 'sum(im1/im1)'
oken: 'sum(im1/im1)'
Position: 0
So I guess my -exp is wrong.
Thanks
Oliver
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/optout.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/optout.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Rémi
2018-09-18 08:39:20 UTC
Permalink
Hi Olivier,
Counting zeros looks tricky. I don't have something simple in mind yet.
Maybe try to sum up values that are positive AND negative?
Rémi
Post by 'O Buck' via otb-users
Dear Remi,
How would I calculate the number of "0" components, i.e. the number of
bands where the pixel value is "0"?
Struggling to understand the muparser logic ;)
oliver
Post by remicres
...or maybe "sizeof(im1')-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
My bad, I thought that you wanted the sum of positive components.
To count only the number of positive component you can use something
like this "54-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
Dear remicres,
I have just tested your expression on a 54 channel image. However the
result.tif is not giving me pixels values between (0-54) but values up to
174600.
Any ideas?
Oliver
You can also do it with BandMathX with the expression
"0.5*(im1+vabs(im1))*ones(sizeof(im1'),1)"
Got it . Needed to use " instead of ' to state the -exp to get it run.
Thanks a lot!!!
Not sure what I am doing wrong.
All it does is to write the error message into a file
Message: Unexpected token "'(im1b1 " found at position 0.
Try without sum : "(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4
0) + (im1b5 > 0)"
Victor Poughon
*Envoyé :* lundi 4 juin 2018 12:20
*Objet :* Re: [otb-users] BandmathX Sum of all bands
Thanks Victor for you fast answer,
otbcli_BandMath -il InIMAGE.img -out OutIMAGEtest.img -exp 'sum((im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 > 0) + (im1b5 > 0))'
is not working and would not give me the number of bands with values >0 but a sum of pixel values, right?
Can I put the exp to 'sum((im1b1/im1b1 > 0) + (im1b2/im1b2 > 0) .....
Since you have a lot of bands, writing the exp by hand will be a
very ugly
 but it should work. You can make a quick python script to
generate the exp.
print(" + ".join(["(im1b" + str(i) + " > 0)" for i in range(1,
61)]))
(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 > 0) + (im1b5 > 0) + (im1b6 > 0) + (im1b7 > 0) + (im1b8 > 0) + (im1b9 > 0) + (im1b10 > 0) + (im1b11 > 0) + (im1b12 > 0) + (im1b13 > 0) + (im1b14 > 0) + (im1b15 > 0) + (im1b16 > 0) + (im1b17 > 0) + (im1b18 > 0) + (im1b19 > 0) + (im1b20 > 0) + (im1b21 > 0) + (im1b22 > 0) + (im1b23 > 0) + (im1b24 > 0) + (im1b25 > 0) + (im1b26 > 0) + (im1b27 > 0) + (im1b28 > 0) + (im1b29 > 0) + (im1b30 > 0) + (im1b31 > 0) + (im1b32 > 0) + (im1b33 > 0) + (im1b34 > 0) + (im1b35 > 0) + (im1b36 > 0) + (im1b37 > 0) + (im1b38 > 0) + (im1b39 > 0) + (im1b40 > 0) + (im1b41 > 0) + (im1b42 > 0) + (im1b43 > 0) + (im1b44 > 0) + (im1b45 > 0) + (im1b46 > 0) + (im1b47 > 0) + (im1b48 > 0) + (im1b49 > 0) + (im1b50 > 0) + (im1b51 > 0) + (im1b52 > 0) + (im1b53 > 0) + (im1b54 > 0) + (im1b55 > 0) + (im1b56 > 0) + (im1b57 > 0) + (im1b58 > 0) + (im1b59 > 0) + (im1b60 > 0)
Victor Poughon
*Envoyé :* lundi 4 juin 2018 11:08
*Objet :* [otb-users] BandmathX Sum of all bands
Dear all,
being new to OTB, my question might be trivial, so apologies if
that is the case.
What I would like to do with otbcli_BandMath is to calculate an
image that gives the sum of all bands representing values >0.
I have an image with nBands (in my test case n=60, but could be
more or less). Each pixel has thus a maximum of 60 values (some bands have
no-data, represented as -1 values).
What I would like to get is an output image, where each pixel value
gives me the amount of bands with values >0 per pixel from the inout image.
I don't know how to set the -exp
Tried with
- otbcli_BandMath -il
G:\PROJEKTE\2518_BfN_Grassland\04_Arbeitsdokumente\test_landsat_path\mask_194_24\layerstack_test_194_24_nodata_clip15.img
-out test.img -exp 'sum(im1/im1)'
but received
itk::ExceptionObject (0000008641989700)
Location: "unknown"
C:\dashboard\otb\src\Modules\Filtering\MathParser\src\otbParser.cxx
Line: 170
Message: Unexpected token "'sum(im1/im1)' " found at position 0.
Formula: 'sum(im1/im1)'
oken: 'sum(im1/im1)'
Position: 0
So I guess my -exp is wrong.
Thanks
Oliver
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/optout.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it,
For more options, visit https://groups.google.com/d/optout.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...