Algorithm to arrange the set of points clockwise and make sure that the path connecting the points is closed

I did this problem differently, and after a month, trying to do it myself, I think it is time for fresh eyes to look at it. I am trying to make an image scaling application to re-select 8-bit sprites and turn them into vector images. So far I am working; it takes an image, breaks it into shapes (areas with adjacent pixels of the same color), and then each pixel in the form is replaced by four pixels:

private Point[] expand(int x, int y){
    x *= factor;
    y *= factor;
    return new Point[]{new Point(x+half_factor,y), new Point(x+factor,y+half_factor),
            new Point(x+half_factor, y+factor), new Point(x,y+half_factor)};
}

Each of the four points is placed in a 2D Boolean array:

private void placePoint(int x, int y){
    table[x][y] = !table[x][y];
    extrema(x,y);
}

And the result for one individual form is as follows:

enter image description here

( , ) , , , , , , . goomba , . , , , .

enter image description here

, :

enter image description here

, , , :

  • , C-, √C

!

UPDATE:

, .

:

enter image description here

:

enter image description here

:

, !

enter image description here

+4
2

  • , .
  • .
  • .

2 3 . 2 , , . ,

***
* *
***
* *

._._._.
|* * *|
. ._. .
|*| |*|
. ._. .
|* * *|
. ._. .
|*| |*|
._. ._.

_ | , . . , , . .

3 : , , , . . , .

+1