views:

72

answers:

1

Possible Duplicate:
How do I calculate the area with matlab (unit : m*h)?

alt text

Don't take the blue,red lines into account, what's the simplest solution to calculate the area of the green box unit(width and height in pixels) with MATLAB?

+1  A: 

Since the grid is perfectly well aligned in the horizontal/vertical, you can use the following algorithm:

  1. Extract the green channel
  2. Threshold the image such that there are 1's wherever there is a green signal, and 0's wherever there is white
  3. To find the spacing in x
    1. Sum the thresholded image along y
    2. Find the local maxima in the summed array
    3. Count how many pixels there are between two local maxima.
  4. Repeat for y
Jonas
This is not accurate,since it doesn't always happen to be N times of units in total.
Standard operation is to remove outliers and take average.
yuk
Right, but in this case it's known before hand that each box is of the same size, so I want to calculate it exactly.
The average of the distances will converge toward the exact distance between peaks. Also, you can calculate the position of the local maximum with sub-'pixel' accuracy (e.g. by fitting a Gaussian into the peak and measuring the position of its center), so that the average converges even faster.
Jonas