change in value of pixel after binarization


I have binarized an image.
And now, I would like to know the number of pixel per line value change.
Is there existing a function to do it ?

For example :
1 line of my image is : (0,0,0,0,0,0,0,0,255,255,255,0,0,0,0,0,0,0,0,255,255,255,255,255,255)
There are 3 changes

I hope to be understandable

thank you

There’s no method to do run length compression in the python interface level. You can either code the algorithm in C and it will run extremely fast or you can code it in Python and it will run very slow.

If you want help coding it in C I can provide the steps.