Hello, there's this problem about line crossings I saw somewhere and was trying to solve.(adsbygoogle = window.adsbygoogle || []).push({});

There's a 64x64 grid of 8 bit pixels and it has a bunch of 1 pixel wide vertical and horizontal lines of different colors on it. All parallel lines have at least one space between them. The problem is to find the number of line crossings that each set of colored lines makes (e.g. all green line crossings count towards one sum). And find which set of lines had the fewest amount of crossings. Also, all vertical lines of a color are the same size and all horizontal lines of the same color are the same size.

I had a few ideas but they all seem pretty inefficient. It would involve going through every pixel in the grid, if you run into a color determine if it's a vertical or horizontal line, and then go in the direction of the line all the while checking adjacent sides for different colors.

I'm trying to decide if first counting the length of the horizontal and vertical lines for each color would speed up the process. DO you guys have any brilliant ideas for how to do this?

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Line crossing algorithm?

Loading...

Similar Threads - Line crossing algorithm | Date |
---|---|

Java Draw circles at end Point of Line with End Points as Centre | Apr 12, 2017 |

Line Styles in a Graph in MATLAB | Jan 26, 2017 |

Latex Cross References, citations etc not working | Dec 4, 2016 |

JavaScript How do I save JSON files to off-line database? | Oct 3, 2016 |

Fortran What does this Fortran Line Mean? | Jul 28, 2016 |

**Physics Forums - The Fusion of Science and Community**