I have picture with an irregular boundary. I draw line on it, but I want to omit the part of the line outside boundary. I have a rather primitive way of doing this with the following code.

im= https://i.sstatic.net/2fmSdwxM.png
fline[{x_, y_}] := If[PixelValue[im, {x, y}][[4]] == 1, Point[{x, y}]]
Graphics[{im, Line[{{175, 242}, {0, 50}}], Red,fline[{175, 242} - # {175, 192}/100]&/@ Range[100]}]
I would like to do this more efficiently, now I have to recalculate the line in Graphics to one according to the pixels of the image. Moreover, the picture will serve as a texture on which the line will be drawn, which is an added difficulty that I cannot solve.




