Skip to main content
added 863 characters in body
Source Link
Niki Estner
  • 36.4k
  • 3
  • 92
  • 156

Probably the best approach to the problem would be to implement an algorithm which allows to generate pixel positions in the original image along the Line without using the FrontEnd

I think ImageTransformation doest just that. Using your definitions:

r = Min[id]/2;
dir = N@AngleVector[α];
(*modify step distance so we step at least 1 pixel in x or y \
direction*)
dir = dir/Max[Abs[dir]];
profile = 
  First@ImageData@
    ImageTransformation[img, 
     center + #[[1]] dir + {1, 0} &, {Round[r], 1}, DataRange -> Full,
      PlotRange -> {{0, r - 1}, {0, 1}}, Resampling -> "Nearest"];

ListLinePlot[{profile, radialProfile}, PlotRange -> All]

enter image description here

There still is an unwanted interpolation, try simple check when α=0 and center = Round[Mean /@ pr];: radialProfile - PixelValue[img, Table[center + i {1, 0}, {i, 1, 502}]] returns only zeros while profile - PixelValue[img, Table[center + i {1, 0}, {i, 1, 501}]] gives many zeros but also many interpolated values.

I agree this is weird. I'm guessing Resampling->"Nearest" interpolates if a coordinate is exactly between two pixels? But I believe this is fixable by rounding coordinates and shifting them to pixel centers (Round[pt]-.5):

profile = 
  First@ImageData@
    ImageTransformation[img, 
     Round[center + #[[1]] dir] - .5 &, {Round[r], 1}, 
     DataRange -> Full, PlotRange -> {{0, r - 1}, {0, 1}}, 
     Resampling -> "Nearest"];

profile - PixelValue[img, Table[center + i {1, 0}, {i, 0, 500}]]

Probably the best approach to the problem would be to implement an algorithm which allows to generate pixel positions in the original image along the Line without using the FrontEnd

I think ImageTransformation doest just that. Using your definitions:

r = Min[id]/2;
dir = N@AngleVector[α];
(*modify step distance so we step at least 1 pixel in x or y \
direction*)
dir = dir/Max[Abs[dir]];
profile = 
  First@ImageData@
    ImageTransformation[img, 
     center + #[[1]] dir + {1, 0} &, {Round[r], 1}, DataRange -> Full,
      PlotRange -> {{0, r - 1}, {0, 1}}, Resampling -> "Nearest"];

ListLinePlot[{profile, radialProfile}, PlotRange -> All]

enter image description here

Probably the best approach to the problem would be to implement an algorithm which allows to generate pixel positions in the original image along the Line without using the FrontEnd

I think ImageTransformation doest just that. Using your definitions:

r = Min[id]/2;
dir = N@AngleVector[α];
(*modify step distance so we step at least 1 pixel in x or y \
direction*)
dir = dir/Max[Abs[dir]];
profile = 
  First@ImageData@
    ImageTransformation[img, 
     center + #[[1]] dir + {1, 0} &, {Round[r], 1}, DataRange -> Full,
      PlotRange -> {{0, r - 1}, {0, 1}}, Resampling -> "Nearest"];

ListLinePlot[{profile, radialProfile}, PlotRange -> All]

enter image description here

There still is an unwanted interpolation, try simple check when α=0 and center = Round[Mean /@ pr];: radialProfile - PixelValue[img, Table[center + i {1, 0}, {i, 1, 502}]] returns only zeros while profile - PixelValue[img, Table[center + i {1, 0}, {i, 1, 501}]] gives many zeros but also many interpolated values.

I agree this is weird. I'm guessing Resampling->"Nearest" interpolates if a coordinate is exactly between two pixels? But I believe this is fixable by rounding coordinates and shifting them to pixel centers (Round[pt]-.5):

profile = 
  First@ImageData@
    ImageTransformation[img, 
     Round[center + #[[1]] dir] - .5 &, {Round[r], 1}, 
     DataRange -> Full, PlotRange -> {{0, r - 1}, {0, 1}}, 
     Resampling -> "Nearest"];

profile - PixelValue[img, Table[center + i {1, 0}, {i, 0, 500}]]
added 128 characters in body
Source Link
Niki Estner
  • 36.4k
  • 3
  • 92
  • 156

Probably the best approach to the problem would be to implement an algorithm which allows to generate pixel positions in the original image along the Line without using the FrontEnd

I think ImageTransformationImageTransformation doest just that. Using your definitions:

r = Min[id]/2;
dir = AngleVector[α];
N@AngleVector[α];
(* modify*modify step distance so we step at least 1 pixel in x or y direction *\
direction*)
dir = dir/Max[Abs[dir]];
profile = 
  First@ImageData@
    ImageTransformation[img, 
     center + #[[1]] dir + {1, 0} &, {Round[r], 1}, DataRange -> Full,
     DataRange PlotRange -> Full{{0, PlotRanger -> Full1}, {0, 1}}, Resampling -> "Nearest"];

ListLinePlot[profileListLinePlot[{profile, radialProfile}, PlotRange -> All]

enter image description hereenter image description here

Probably the best approach to the problem would be to implement an algorithm which allows to generate pixel positions in the original image along the Line without using the FrontEnd

I think ImageTransformation doest just that. Using your definitions:

r = Min[id]/2;
dir = AngleVector[α];

(* modify step distance so we step at least 1 pixel in x or y direction *)
dir = dir/Max[Abs[dir]];
profile = 
  First@ImageData@
    ImageTransformation[img, center + #[[1]] dir &, {Round[r], 1}, 
     DataRange -> Full, PlotRange -> Full, Resampling -> "Nearest"];

ListLinePlot[profile, PlotRange -> All]

enter image description here

Probably the best approach to the problem would be to implement an algorithm which allows to generate pixel positions in the original image along the Line without using the FrontEnd

I think ImageTransformation doest just that. Using your definitions:

r = Min[id]/2;
dir = N@AngleVector[α];
(*modify step distance so we step at least 1 pixel in x or y \
direction*)
dir = dir/Max[Abs[dir]];
profile = 
  First@ImageData@
    ImageTransformation[img, 
     center + #[[1]] dir + {1, 0} &, {Round[r], 1}, DataRange -> Full,
      PlotRange -> {{0, r - 1}, {0, 1}}, Resampling -> "Nearest"];

ListLinePlot[{profile, radialProfile}, PlotRange -> All]

enter image description here

added 70 characters in body
Source Link
Niki Estner
  • 36.4k
  • 3
  • 92
  • 156

Probably the best approach to the problem would be to implement an algorithm which allows to generate pixel positions in the original image along the Line without using the FrontEnd

I think ImageTransformation doest just that. Using your definitions:

r = Norm[id]Min[id]/2;
profiledir = AngleVector[α];

(* modify step First@ImageData@distance so we step at least 1 pixel in x or y direction *)
dir = dir/Max[Abs[dir]];
profile = ImageTransformation[
  First@ImageData@
   img ImageTransformation[img, center + #[[1]] AngleVector[α]dir &, {Round[r], 1}, 
     DataRange -> Full, PlotRange -> Full];Full, Resampling -> "Nearest"];

ListLinePlot[profile, PlotRange -> All]

enter image description hereenter image description here

Probably the best approach to the problem would be to implement an algorithm which allows to generate pixel positions in the original image along the Line without using the FrontEnd

I think ImageTransformation doest just that. Using your definitions:

r = Norm[id]/2;
profile = 
  First@ImageData@
    ImageTransformation[
     img, center + #[[1]] AngleVector[α] &, {Round[r], 1}, 
     DataRange -> Full, PlotRange -> Full];

ListLinePlot[profile, PlotRange -> All]

enter image description here

Probably the best approach to the problem would be to implement an algorithm which allows to generate pixel positions in the original image along the Line without using the FrontEnd

I think ImageTransformation doest just that. Using your definitions:

r = Min[id]/2;
dir = AngleVector[α];

(* modify step distance so we step at least 1 pixel in x or y direction *)
dir = dir/Max[Abs[dir]];
profile = 
  First@ImageData@
    ImageTransformation[img, center + #[[1]] dir &, {Round[r], 1}, 
     DataRange -> Full, PlotRange -> Full, Resampling -> "Nearest"];

ListLinePlot[profile, PlotRange -> All]

enter image description here

Source Link
Niki Estner
  • 36.4k
  • 3
  • 92
  • 156
Loading