I have curve with a set of peaks (black line in the figure below) and I have to calculate the area of each peak. At the end of each peak there is a short linear region. So to calculate peaks' area first I should calculate the curve which pass smoothly through all linear regions of my initial curve (red line). I know I should provide some code where I attempt to solve the problem, but I have no any idea how to do it, sorry.
Here is data for my curve
data = << "http://pastebin.com/raw/kAdkHpQn";
The shape of peaks could be very different. Moreover it could be several maximums inside one peak. The only definite thing is that there is linear region after each peak. A add some more examples of my curves