5
$\begingroup$

This question already has an answer here:

There is a image of Black Sea from "Google Earth".

enter image description here

I want to calculate area of black sea from this image using Mathematica

The length of yellow line on this image is $100$ km (scale.)

I try to detect of edge of sea shape

enter image description here

 DominantColors[sea, Automatic, {"CoverageImage", "Color"}]

enter image description here

Then (from this question)

Count[Flatten@ImageData@sea,0]

658041

The correct value of area is 436,402 km²

Does there exists another way to calculate this area?

Sorry for my English. Thanks!

$\endgroup$

marked as duplicate by Dr. belisarius, MarcoB, user9660, dr.blochwave, rhermans Feb 25 '16 at 13:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 6
    $\begingroup$ Possible duplicate $\endgroup$ – Simon Woods Feb 24 '16 at 19:46
  • $\begingroup$ If you measure the length of the yellow line, it should be pixelCount * (Quantity[100,"Kilometers"] / lengthOfYellowLine)^2. But don't expect good accuracy, since the yellow line is relatively short. $\endgroup$ – Niki Estner Feb 24 '16 at 19:52
5
$\begingroup$

Using binarize segmentation and component analysis.

img = Import["http://i.stack.imgur.com/FZRNj.jpg"];
chan = ChanVeseBinarize[img];
comp = ComponentMeasurements[chan, {"Shape", "Area"}]

enter image description here

Components 8 and 10 are of interest. The diagonal of the shape 10 is approximately our 100 km mark. Let's use that measurement as our scaling factor.

scale = Sqrt@Total[ImageDimensions[c[[10, 2, 1]]]^2] // N
(*116.103*)

area = (comp[[8, 2, 2]] + comp[[10, 2, 2]])*(100/scale)^2
(*438,392.*)
real = QuantityMagnitude[
  WolframAlpha["area of black sea", {{"Result", 1}, "QuantityData"}, 
   PodStates -> {"Result__Show metric"}]]
percentError = 100 (area - real)/real
(*0.456455%*)
$\endgroup$
9
$\begingroup$

Not really too accurate but here goes. We start as in the original post. The region of interest is the second one (or first, if we reverse 0's and 1's). We'll count zeros to get the area in terms of the pixel dimensions.

regions = 
  DominantColors[sea, Automatic, {"CoverageImage", "Color"}];
searegion = regions[[2, 1]];
seadata = ImageData[searegion];
seaarea = Count[seadata, 0, {2}];

yelseg = PixelValuePositions[sea, Yellow, .3]

(* Out[64]= {{512, 596}, {513, 595}, {518, 589}, {529, 576}, {539, 
  564}, {560, 539}, {565, 533}, {569, 528}, {571, 526}, {576, 
  520}, {580, 515}, {582, 513}} *)

This is not alone enough for the segment length. We need the red dot as well.

reddot = PixelValuePositions[sea, Red, .3]

(* Out[70]= {{506, 604}, {507, 604}, {508, 604}, {509, 604}, {505, 
  603}, {506, 603}, {507, 603}, {508, 603}, {509, 603}, {510, 
  603}, {505, 602}, {506, 602}, {507, 602}, {508, 602}, {509, 
  602}, {510, 602}, {505, 601}, {506, 601}, {507, 601}, {508, 
  601}, {509, 601}, {510, 601}, {505, 600}, {506, 600}, {507, 
  600}, {508, 600}, {509, 600}, {510, 600}, {506, 599}, {507, 
  599}, {508, 599}, {509, 599}, {510, 599}} *)

Now we can gauge dimension.

seglen = N[EuclideanDistance[reddot[[1]], yelseg[[-1]]]]

(* Out[71]= 118.562219952 *)

THis means 100 pixels is around 118-119 km. So with that normalization we can estimate the area in km^2.

seaarea*(100/seglen)^2

(* Out[72]= 451257.736359 *)

How did we do?

In[77]:= WolframAlpha["surface area of Black Sea in km^2", "Result"]

(* Out[77]= Quantity[4.364*10^5, ("Kilometers")^2] *)

Not bad, at that.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.