Taking a slice of a two dimensional array

  • Context: Undergrad 
  • Thread starter Thread starter jing2178
  • Start date Start date
  • Tags Tags
    Array
Click For Summary

Discussion Overview

The discussion revolves around the mathematical and computational aspects of taking a slice from a two-dimensional array of numbers. Participants explore methods for selecting elements based on a line drawn across the array, considering the implications of different approaches and their applications.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested

Main Points Raised

  • One participant notes the complexity of defining a 1-dimensional slice from a 2D array and questions existing methods and potential improvements.
  • Another participant suggests that multiple methods for selecting pixels are possible, including alternating lower and upper pixels, and emphasizes that the choice of method depends on the specific application.
  • A reference to Bresenham's line algorithm is provided as a potential method for determining which pixels are intersected by the line.
  • A later reply acknowledges the need to consider the projection of the line on boundary lines parallel to the axes, indicating a further layer of complexity in the representation.

Areas of Agreement / Disagreement

Participants present multiple competing views on how to approach the problem, with no consensus on a single best method or solution.

Contextual Notes

Participants express uncertainty regarding the best method for pixel selection and the implications of different approaches, highlighting the dependence on specific applications and the need for further exploration of the problem.

jing2178
Messages
41
Reaction score
2
The source of this question is an unanswered question at stackoverflow but I believe is more mathematical than computational.

My question arising from this is.

You have a two dimensional array of numbers, each element of the array is represented by a square box. The boxes arranged into a rectangle with element (i,j) represented by the box in position (i,j). A 1-dimensional slice of the array is formed by drawing a line across the boxes, choosing boxes based on the position of the line crossing them and a vector formed on the basis of the chosen boxes.

This pdf file shows an issue arising following one attempt to do this.

Are there already recognised ways of doing this?
Are there better ways of doing this than the way I have tried?
Can the question be stated in a more succinct way?

Any help please.
 
Mathematics news on Phys.org
All 3 methods are possible - and you could take alternating lower/upper pixel as well if "combined pixel" is not practical for some reason.
To make things even more complicated: The cell right of 2 is not hit in the center - you could try to take that into account as well.

Which method is best for you depends on the application.
 
NemoReally said:

Thank you that is useful. As it is still a 2D representation of the line I think I will need to look at the projection of the line (and hence pixels) on boundary lines parallel to the axes.
 

Similar threads

  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 29 ·
Replies
29
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K