No products are associated with this question.
What you're asking is a fairly difficult problem especially if this is a scanned image.
If I were to attempt it, first I'd hope that it was as color scan so the red graph lines could be easily separated from the black trace. And that it was well aligned so rotation could be minimized if not eliminated.
Then the red graph lines would have to be identified in both dimensions to get a conversion from pixels on the y-axis to mm and pixels on the x-axis to ms.
Thresholding the blue/green channels should give a decent binary image of the trace and stepping through the x-axis finding the location of the trace you can convert that to a vector of mm offset.
Finding R is easy but there are so many possible variations of q and t that it takes some pretty smart pattern matching algorithms. I'd suggest a literature search and some reading before you start.
If this is a 12 lead EKG the problem is a lot harder yet.
If all you want is to extract one qrst complex and extract a picture it's easier because you can just find a couple of R waves and make a box around them.
Enough generalizations and hypotheticals, perhaps if you give us more details on what exactly you're trying to do we can be more specific.
You could try this: http://www.mathworks.com/matlabcentral/fileexchange/36904-matlab-script-for-digitizing-a-published-graph to manually (by clicking) input the waveform, but I'd only do it as a last resort. Image analysis would be another option but you'd have to write a program to do that and I'm not sure how hard it would be because I haven't seen your image and I don't know your programming skills or experience with image analysis programming. Even for me it would probably take a few hours depending on how user friendly, flexible, general, and robust I wanted to make it.
You don't need to use MATLAB. Try:
If 5.1 doesn't work, navigate up to the Parent Folder and try 4.1 - that seems to be fine. There is a manual, accompanied by sample data sets. The s/w can work automatically or you can supply individual points with mouse clicks. Scanned images for i/p may be in a variety of formats - be prepared to experiment.
If you still want to use MATLAB, then getting started is easy - from a binary scan of your graph, use:
[ y, x ] = find(ScannedImage == 0);
In practice, cleaning up a dirty scan (with wide and uneven lines on a speckled or annotated background) is likely to be hard. So, try an off-the-shelf solution first.