Talk:Marching squares

From Rosetta Code
Revision as of 07:43, 30 June 2022 by Rdm (talk | contribs) (→‎Task needs work: fix wikipedia interwiki link (note: preview suggests that the interwiki code might be broken - saving page as-is to test))

Task needs work

Currently, the task description does not allow us to determine whether an implementation is correct.

The referenced wiki pages represent an image transformation, but currently no tasks here generate images (and this site is poorly equipped to represent images).

Instead, some of the tasks currently represent a transformation from a bitmap to a sequence of non-unique coordinates, but it's not clear that those coordinates represent the marching squares image transformation.

Specifically, we see:

0 0 0 0 0
0 0 0 0 0
0 0 1 1 0
0 0 1 1 0
0 0 0 0 0

being transformed into a sequence of 11 coordinates pairs which correspond to 9 distinct coordinates arranged like this:

0 0 0 0 0
0 0 1 1 0
0 1 0 0 1
1 0 0 0 1
0 1 1 1 0

This transformation lacks symmetry which makes it suspect. But currently there's nothing in the task description to help us understand this issue.

In contrast, the Wren and Phix solutions start from this bitmap

0 0 0 0 0
0 0 0 0 0
0 0 1 1 0
0 0 1 1 0
0 0 0 1 0
0 0 0 0 0

and identify a path with length 11 composed of 10 unique coordinates which would probably correspond to these positions (or maybe this should be shifted up and to the left by one grid coordinate? I'm guessing because I don't know whether the 0,0 coordinate would correspond to the upper left hand corner of the bitmap or if it would be outside the bitmap):

0 0 0 0 0
0 0 0 0 0
0 0 1 1 1
0 0 1 0 1
0 0 1 1 1
0 0 0 1 1

Again, this lacks symmetry. But this result is not comparable to the other result because the starting bitmap was different (and also was not symmetric). This one, at least, seems to correspond more closely to the shape of the initial bitmap.

Possibly all of these results are correct. Possibly not. Currently the task is too ambiguous. --Rdm (talk) 01:34, 30 June 2022 (UTC)

Looking at this more closely, the implementation of identifyPerimeter at http://www.tomgibara.com/computer-vision/MarchingSquares.java is unable to identify diagonal contour lines, even though half of the contour lines in the lookup table of the basic algorithm are diagonals. Also, that identifyPerimeter implementation finds only one contour line (and only if that contour line corresponds to a perimeter which touches the center of the image). --Rdm (talk)