Hello,
I would require to create an image measurement tool (to measure distance between objects in an image) in Mathematica.
It is not available in the documentation.
Thanks
Hello,
I would require to create an image measurement tool (to measure distance between objects in an image) in Mathematica.
It is not available in the documentation.
Thanks
Hello Man Oj,
with Mathematica it is no problem to make such a tool. Here comes a simple example:
fourLocators[img_Image, mag_: 1] := DynamicModule[{imgdim, pt0, pt},
imgdim = ImageDimensions[img];
pt0 = {imgdim[[1]]/2, imgdim[[2]]/2};
pt = {pt0 + {1, 1}, pt0 + {1, -1}, pt0 + {-1, 1}, pt0 + {-1, -1}};
Column@{LocatorPane[Dynamic[pt],
Image[img, ImageSize -> mag imgdim],
Appearance -> {Style["+", Red], Style["+", Red],
Style["+", Green], Style["+", Green]}],
Dynamic["DistRed" -> EuclideanDistance[pt[[1]], pt[[2]]]],
Dynamic["DistGreen" -> EuclideanDistance[pt[[3]], pt[[4]]]]}
]
Letβs try:
img = Image@DensityPlot[Sin[x] Cos[y/2], {x, -5, 5}, {y, -5, 5}, Frame -> False, PlotPoints -> 50];
fourLocators[img]
gives

Here the distances are given in terms of image pixels.
Hope that helps, regards β Henrik
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=fourLocators.gif&userId=32203
A simpler alternative to @Henrikβs nice version:
i = ExampleData[{"TestImage", "House"}];
Manipulate[
Labeled[Show[i, Graphics[Line[pt]]], EuclideanDistance @@ pt],
{{pt, Min[ImageDimensions[i]] {{.3, .3}, {.6, .6}}}, Locator}]
Dear @Vitaliy Kaurov,
excellent - I always prefer simple solutions! Thanks for sharing!
Best regards β Henrik
Hi Vitality/Henrik,
Thanks for help.
Regs