# How can I plot these straight lines in a picture?

## How can I plot these straight lines in a picture?

min = 10;
max = 40;
l = 12;
d = 5;
p = 0.5;
x1 = l/((1/min - 1/max)/(1/max));
k = 1/(max*x1);
n = d/2*min;
Do[Plot[{(i + p/2)*x, (i - p/2)*x}, {x, x1, l},
Filling -> {1 -> {{2}, Black}}], {i, -n, n}]


Should I use Table?I want to overlay lines into an image.But I don't know how to do it. Thank you.

Emm,I solve the half of problem.But now I can only get the half of the picture.

• I'm afraid "in a picture" is ambiguous, this need clarification. It's not clear if you want to export into an image files or overlay lines into an image, nor if is many lines in a single image or one line per image. or probably something different. Please edit your question to clarify, use the comments section only for comments. – rhermans Jul 26 at 10:05
• And by the way, welcome to Mma.SE. Thanks for taking the tour. Be sure you have learned about asking and what's on-topic. Is best to edit if improvable, or to show due diligence, give context, include minimal working example of code and data. Thanks for using formatted form. By doing all this you help us to help you and likely you will inspire great answers. The site depends on participation, as you receive give back: vote and answer questions, keep the site useful, be kind share what you have learned. – rhermans Jul 26 at 10:10
• I’m sorry for my expression.Thank you. – saltkun Jul 26 at 10:12
• We understand that explaining may be difficult, there is no need to be sorry, it's fine. We just need as much information as possible to understand what is that you need exactly. With no information we can only guess. – rhermans Jul 26 at 10:34

lines = Show[Table[Plot[{(i + p/2)*x, (i - p/2)*x}, {x, x1, l},
Filling -> {1 -> {{2}, Black}}, PlotStyle -> None], {i, -n, n}],
AspectRatio -> 1, Axes -> False];

picture = ExampleData[{"TestImage", "Lena"}];


Rasterize lines with a transparent background and resize it to have the same size as picture:

rasterizedlines = ImageResize[Rasterize[lines,
ImageResolution -> 300, Background -> None],
ImageDimensions[picture]]

1. You can use ImageCompose to show picture and rasterizedlines overlayed:
ImageCompose[picture, rasterizedlines]


1. You can raster lines as graphics and use it as Epilog to picture:
rasterizedlines2 = Rasterize[lines, "Graphics",
ImageResolution -> 300,
Background -> None,
ImageSize -> ImageDimensions[picture]]

Show[picture, Epilog -> First[rasterizedlines2]]


1. You can use picture as Prolog in Show:
raster = Rasterize[picture, "Graphics"][[1]];
raster[[2]] = {Scaled[{0, 0}], Scaled[{1, 1}]};

Show[lines,  Prolog -> raster]


Module[
{
min = 10, max = 40, l = 12, d = 5, p = 0.5, x1, k, n,
lines,
image = ExampleData[{"TestImage", "Boat"}],
plot
},
x1 = l/((1/min - 1/max)/(1/max));
k = 1/(max*x1);
n = d/2*min;
lines = Flatten@Table[
{(i + p/2)*x, (i - p/2)*x}
, {i, -n, n}];
plot = Plot[
lines
, {x, x1, l}
, Filling -> {1 -> {{2}, Black}}
, PlotStyle -> Array[Hue, Length[lines], {0, 0.8}]
, PlotTheme -> "Minimal"
];
Overlay[{image, plot}]
]