In order to automate the process of finding the Orientation of the pattern in an image, I would like to first find the center of a circular specimen. Original image can be downloaded here. My current progress and the results are described further on.
I can get some sort of circular shaped 2D object using the following set of commands:
DeleteSmallComponents@Colorize@MorphologicalComponents[image]
, which results in
Using built-in ComponentMeasurements[]
in the following code
pos = ComponentMeasurements[DeleteSmallComponents@
Colorize@MorphologicalComponents[image], "BoundingDiskCenter"]
and plotting a point on an image with the code
PointPlot=ListPlot[{{pos[[1, 2, 1]], pos[[1, 2, 2]]}},
PlotStyle -> Directive[Red, PointSize -> Medium]];
Show[{image, PointPlot}, ImageSize -> Full]
gives the center as:
As you can see, the point is not at exact center of the circle. I have tried using ImageCorrelation with the white disk on the black background, but I cannot manage to match the size of the specimen with the size of the disk. I apologize for bad code formatting, but I have no idea how to improve it.
Show[#2, ListPlot[{{#1[[1, 2, 1]], #1[[1, 2, 2]]}}, PlotStyle -> Directive[Red, PointSize -> Medium]], ImageSize -> Automatic] &[Sequence @@ {ComponentMeasurements[#, "BoundingDiskCenter"], #}&@DeleteSmallComponents@Colorize@MorphologicalComponents[image]]
and tell us what your problem is. $\endgroup$Show[#2, ListPlot[{{#1[[1, 2, 1]], #1[[1, 2, 2]]}}, PlotStyle -> Directive[Red, PointSize -> Medium]], ImageSize -> Full] &[ Sequence @@ {ComponentMeasurements[#, "BoundingDiskCenter"], #} &@ image]
to exactly replicate my example. $\endgroup$