Question: I recorded the following `image` (28$\times$28 pixels) showing a bright square object (I used a square object of 35 micrometers side length and imaged it with a microscope):

[![enter image description here](https://i.stack.imgur.com/2uAtN.png)](https://i.stack.imgur.com/2uAtN.png)

Scaled to pixel size (for better visualization) it looks the following:

[![enter image description here](https://i.stack.imgur.com/5ktS0.png)](https://i.stack.imgur.com/5ktS0.png)

How can I determine the side length?

I started with: 

```
data = ImageData[image, "Byte"];
ListLinePlot[data[[All, 14]], ImageSize -> Medium]

```

which gives:

[![enter image description here](https://i.stack.imgur.com/voYXP.png)](https://i.stack.imgur.com/voYXP.png)

and in 3d:

```
ListPlot3D[ImageData[image,"Byte"]]

```

[![enter image description here](https://i.stack.imgur.com/HX7Oa.png)](https://i.stack.imgur.com/HX7Oa.png)

Now I could determine the mean position of the strongest slope at both edges and determine from that the side length.

How would you proceed? Are there image analysis functions existing which can be used to detect the edges to subpixel resolution?

Answer: 
```
data = ImageData[i1]; 
s = Select[Split@MaxDetect[GradientFilter[#, 2], 1/100] & /@ 
                                  Join[data, Transpose@data], Length@# == 5 &];
Length[#[[2]]/2] + Length@#[[3]] + Length[#[[4]]/2] & /@ s // Mean // N

(* 19.878 *)

```
This estimates the side length at nearly 21:

```
edges = EdgeDetect[image];
ComponentMeasurements[
 WatershedComponents[Closing[edges, 0.5], CornerNeighbors -> False],
 "Area"]
Sqrt[1 /. %]    (* using area to estimate a square *)
(*
  {1 -> 437.375, 2 -> 283.375}
  20.9135
*)

```

This is what `edges` looks like:

![Mathematica graphics](https://i.stack.imgur.com/BCee2.png)