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

Le jeudi 13 septembre 2018 10:28:28 UTC+2, O Buck a écrit :
>
> 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
>
>
>
> Am Donnerstag, 7. Juni 2018 11:57:34 UTC+2 schrieb Rémi:
>>
>> ...or maybe "sizeof(im1')-0.5*(vabs(im1)-im1)*ones(sizeof(im1'),1)"
>>
>> Le jeudi 7 juin 2018 11:56:19 UTC+2, remicres a écrit :
>>>
>>> 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)"
>>>
>>> Le jeudi 7 juin 2018 11:37:55 UTC+2, O Buck a écrit :
>>>>
>>>> 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
>>>>
>>>>
>>>> Am Dienstag, 5. Juni 2018 17:25:13 UTC+2 schrieb remicres:
>>>>>
>>>>> You can also do it with BandMathX with the expression 
>>>>> "0.5*(im1+vabs(im1))*ones(sizeof(im1'),1)" 
>>>>>
>>>>>
>>>>> Le lundi 4 juin 2018 13:50:29 UTC+2, O Buck a écrit :
>>>>>>
>>>>>> Got it . Needed to use " instead of ' to state the -exp to get it run.
>>>>>>
>>>>>> Thanks a lot!!!
>>>>>>
>>>>>> Am Montag, 4. Juni 2018 13:31:46 UTC+2 schrieb O Buck:
>>>>>>>
>>>>>>> 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.
>>>>>>>
>>>>>>>
>>>>>>> Am Montag, 4. Juni 2018 13:21:14 UTC+2 schrieb Poughon Victor:
>>>>>>>>
>>>>>>>> Try without sum : "(im1b1 > 0) + (im1b2 > 0) + (im1b3 > 0) + (im1b4 
>>>>>>>> > 0) + (im1b5 > 0)"
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> Victor Poughon
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> *De :* 'O Buck' via otb-users [mailto:otb-...@googlegroups.com] 
>>>>>>>> *Envoyé :* lundi 4 juin 2018 12:20
>>>>>>>> *À :* otb-users <otb-...@googlegroups.com>
>>>>>>>> *Objet :* Re: [otb-users] BandmathX Sum of all bands
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> Thanks Victor for you fast answer,
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> but I am still not sure if I set the exp right. Assume a 5 band 
>>>>>>>> image:
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> 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) .....
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>>
>>>>>>>> Am Montag, 4. Juni 2018 12:02:03 UTC+2 schrieb Poughon Victor:
>>>>>>>>
>>>>>>>> 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
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> *De :* 'O Buck' via otb-users [mailto:otb-...@googlegroups.com] 
>>>>>>>> *Envoyé :* lundi 4 juin 2018 11:08
>>>>>>>> *À :* otb-users <otb-...@googlegroups.com>
>>>>>>>> *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
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> c:\dashboard\otb\src\modules\filtering\mathparser\include\otbBandMathImageFilter.txx:301:
>>>>>>>>   
>>>>>>>>                                                                        
>>>>>>>>      
>>>>>>>>                                   
>>>>>>>>
>>>>>>>> itk::ERROR: BandMathImageFilter(000001F5309D1BC0):                  
>>>>>>>>                                                                        
>>>>>>>>      
>>>>>>>>                                                          
>>>>>>>>
>>>>>>>> itk::ExceptionObject (0000008641989700)                            
>>>>>>>>                                                                        
>>>>>>>>      
>>>>>>>>                                                           
>>>>>>>>
>>>>>>>> Location: "unknown"                                                
>>>>>>>>                                                                        
>>>>>>>>      
>>>>>>>>                                                          
>>>>>>>>
>>>>>>>> File: 
>>>>>>>> C:\dashboard\otb\src\Modules\Filtering\MathParser\src\otbParser.cxx    
>>>>>>>>     
>>>>>>>>                                                                        
>>>>>>>>      
>>>>>>>>                                       
>>>>>>>>
>>>>>>>> Line: 170                                                          
>>>>>>>>                                                                        
>>>>>>>>      
>>>>>>>>                                                          
>>>>>>>>
>>>>>>>> Description: itk::ERROR: ParserImpl(000001F53FE2C9C0):              
>>>>>>>>                                                                        
>>>>>>>>      
>>>>>>>>                                                         
>>>>>>>>
>>>>>>>> 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 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.
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> -- 
>>>>>>>> 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.
>>>>>>>>
>>>>>>>

-- 
-- 
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-users@googlegroups.com
To unsubscribe from this group, send email to
otb-users+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to