You can't just reference an object within a filter, you have to import it with feImage first - doing this is not supported on Firefox and sizing is occasionally wonky on IE. You should also put your fill pattern into your defs. Here is a larger version that works on safari/chrome - adding feTile so you can see the effect a little more clearly:
<svg width="400px" height="400px">
<defs>
<g id="line">
<line x1="10" y1="10" x2="20" y2="20" stroke="red"/>
<line x1="20" y1="20" x2="30" y2="10" stroke="orange"/>
<line x1="30" y1="10" x2="40" y2="20" stroke="green"/>
<line x1="40" y1="20" x2="50" y2="10" stroke="blue"/>
</g>
<filter id="f1" x="0%" y="0%" height="100%" width="100%">
<feImage xlink:href="#line" width="50" height="20" result="myPattern"/>
<feTile in="myPattern" result="tilePattern"/>
<feBlend mode="normal" in="tilePattern" in2="SourceGraphic"/>
</filter>
</defs>
<g id="rect" filter="url(#f1)">
<rect x="10" y="30" width="300" height="300" stroke="black" stroke-width="2"/>
</g>
</svg>
Now, if you actually want to convert these colors to gradients, you'll have to do that in JavaScript. There is, in theory, a way to do it in a filter by using fillPaint and strokePaint, but these are supported in IE and Firefox only. I'm also not entirely sure what effect you're trying to accomplish, posting an image of what you're trying to do would be helpful.