Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

If you don't need the rectangle you can easyly find the line for Intensity Profile as you mention.

img=import["https://i.sstatic.net/r6cDj.png"]; mf1 = MeanFilter[img, 5]; ht1 = HistogramTransform[mf1]; i = SelectComponents[ SelectComponents[ColorNegate@Binarize[ht1], Small], Large] 

enter image description here

See this answer herehere

lineByCenter[center_, semi_, angle_] := Rotate[Line[{#1 - #2, #1 + #2}], angle, #1] &[center, {0, semi}] sa = 1 /. ComponentMeasurements[i, "SemiAxes"] 

{113.783, 44.4184}

angle = 1 /. ComponentMeasurements[i, "Orientation"] 

-3.14122

bb = Last /@ ComponentMeasurements[i, "BoundingBox"] // First 

{{0., 320.}, {235., 410.}}

bbc = Mean /@ bb 

{117.5, 365.}

Show[i, Graphics[{Yellow, Opacity [0.5], Rectangle[bb[[1]], bb[[2]]], Thick, Red, Rotate[Circle[bbc, sa], angle, bbc], Blue, lineByCenter[bbc, sa[[1]], angle + Pi/2], Green, lineByCenter[bbc, sa[[2]], angle]}]] 

enter image description here

If you don't need the rectangle you can easyly find the line for Intensity Profile as you mention.

img=import["https://i.sstatic.net/r6cDj.png"]; mf1 = MeanFilter[img, 5]; ht1 = HistogramTransform[mf1]; i = SelectComponents[ SelectComponents[ColorNegate@Binarize[ht1], Small], Large] 

enter image description here

See this answer here

lineByCenter[center_, semi_, angle_] := Rotate[Line[{#1 - #2, #1 + #2}], angle, #1] &[center, {0, semi}] sa = 1 /. ComponentMeasurements[i, "SemiAxes"] 

{113.783, 44.4184}

angle = 1 /. ComponentMeasurements[i, "Orientation"] 

-3.14122

bb = Last /@ ComponentMeasurements[i, "BoundingBox"] // First 

{{0., 320.}, {235., 410.}}

bbc = Mean /@ bb 

{117.5, 365.}

Show[i, Graphics[{Yellow, Opacity [0.5], Rectangle[bb[[1]], bb[[2]]], Thick, Red, Rotate[Circle[bbc, sa], angle, bbc], Blue, lineByCenter[bbc, sa[[1]], angle + Pi/2], Green, lineByCenter[bbc, sa[[2]], angle]}]] 

enter image description here

If you don't need the rectangle you can easyly find the line for Intensity Profile as you mention.

img=import["https://i.sstatic.net/r6cDj.png"]; mf1 = MeanFilter[img, 5]; ht1 = HistogramTransform[mf1]; i = SelectComponents[ SelectComponents[ColorNegate@Binarize[ht1], Small], Large] 

enter image description here

See this answer here

lineByCenter[center_, semi_, angle_] := Rotate[Line[{#1 - #2, #1 + #2}], angle, #1] &[center, {0, semi}] sa = 1 /. ComponentMeasurements[i, "SemiAxes"] 

{113.783, 44.4184}

angle = 1 /. ComponentMeasurements[i, "Orientation"] 

-3.14122

bb = Last /@ ComponentMeasurements[i, "BoundingBox"] // First 

{{0., 320.}, {235., 410.}}

bbc = Mean /@ bb 

{117.5, 365.}

Show[i, Graphics[{Yellow, Opacity [0.5], Rectangle[bb[[1]], bb[[2]]], Thick, Red, Rotate[Circle[bbc, sa], angle, bbc], Blue, lineByCenter[bbc, sa[[1]], angle + Pi/2], Green, lineByCenter[bbc, sa[[2]], angle]}]] 

enter image description here

Source Link
s.s.o
  • 4.6k
  • 2
  • 28
  • 43

If you don't need the rectangle you can easyly find the line for Intensity Profile as you mention.

img=import["https://i.sstatic.net/r6cDj.png"]; mf1 = MeanFilter[img, 5]; ht1 = HistogramTransform[mf1]; i = SelectComponents[ SelectComponents[ColorNegate@Binarize[ht1], Small], Large] 

enter image description here

See this answer here

lineByCenter[center_, semi_, angle_] := Rotate[Line[{#1 - #2, #1 + #2}], angle, #1] &[center, {0, semi}] sa = 1 /. ComponentMeasurements[i, "SemiAxes"] 

{113.783, 44.4184}

angle = 1 /. ComponentMeasurements[i, "Orientation"] 

-3.14122

bb = Last /@ ComponentMeasurements[i, "BoundingBox"] // First 

{{0., 320.}, {235., 410.}}

bbc = Mean /@ bb 

{117.5, 365.}

Show[i, Graphics[{Yellow, Opacity [0.5], Rectangle[bb[[1]], bb[[2]]], Thick, Red, Rotate[Circle[bbc, sa], angle, bbc], Blue, lineByCenter[bbc, sa[[1]], angle + Pi/2], Green, lineByCenter[bbc, sa[[2]], angle]}]] 

enter image description here