I think my comment was misunderstood: Looking at the attached image, I'm not sure the information is there. That is, even the ideal image processing algorithm that can do anything, will not be able to count the number of leafs simply because the resolution at which the image is taken is not enough.
– ShaiJan 28 '16 at 11:51
Start with taking an image with MUCH MUCH higher resolution: in order to do the counting, you need that each leaf will be (much) larger than a pixel.
– ShaiJan 28 '16 at 11:59
1
Before you start thinking about doing a task like this, try to write a pseudo-code. If you can't explain with words _exactly_ what you want your code to do then you are very likely to fail. If you already have a concise idea for how you want to do this then please share it! For instance: 1, Find the angle of the image and rotate it so that each page is horizontally aligned. 2. Find a _very specific_ feature that differentiate the pages from the rest of the manuscript and crop the picture. 3. Convert it to black and white. 4.Count the number of black lines. But first of all, get a better image!
– Stewie GriffinJan 28 '16 at 12:04
I agree with @Shai. It looks like that there is no enough information on that image to count the amount of pages.
– Ander BiguriJan 28 '16 at 14:48
@StewieGriffin if you want to find the angle of the image and horizontally align it, you can find [this tutorial](http://stackoverflow.com/a/32228759/1714410) useful ;)
– ShaiJan 28 '16 at 14:51
There are existing algorithms to do this, tho' mostly proprietary. For example, if the pages are reasonably well-maintained, a high-resolution scan will generate a vaguely sinusoidal output because the brightness varies from edge to "between-edge" . If you need an exact count, it's unlikely that any imaging system will work. If you just need, say 99% accuracy, it's possible.
– Carl WitthoftJan 28 '16 at 15:43