1
$\begingroup$

I have writing a code in order to get pixel values of a image along a line. I want to repeatedly to apply the function to the image to get pixel values along multiple lines. My question is how can create such loop in mathematica.

IMGV1 = ImageValue[img, Table[{i, 1111}, {i, 300, 2451, 0.5}]];
IMGV2 = ImageValue[img, Table[{i, 1112}, {i, 300, 2451, 0.5}]];
IMGV3 = ImageValue[img, Table[{i, 1113}, {i, 300, 2451, 0.5}]];
IMGV4 = ImageValue[img, Table[{i, 1114}, {i, 300, 2451, 0.5}]];
IMGV5 = ImageValue[img, Table[{i, 1115}, {i, 300, 2451, 0.5}]];
IMGV6 = ImageValue[img, Table[{i, 1116}, {i, 300, 2451, 0.5}]];
$\endgroup$
  • 2
    $\begingroup$ It sounds highly unlikely that you'll do better than a built-in function. What exactly do you want to achieve, and how exactly do you need your output to look like? (Keep this in mind, by the way.) $\endgroup$ – Emilio Pisanty Aug 9 '16 at 13:21
  • $\begingroup$ Not sure I completely understand. Can't you just do {IMGV1,IMGV2,....}=Table[ImageValue[img,Table[{i,j}....]],{j,1111,...}]? $\endgroup$ – Feyre Aug 9 '16 at 13:25
  • $\begingroup$ @Feyre, Yes, you are right I can create multiple variables with iterated names and assign them with each tuple. $\endgroup$ – Ji Daoyuan Aug 9 '16 at 13:52
  • $\begingroup$ Have you seen ImageData and ImageTake? $\endgroup$ – Michael E2 Aug 9 '16 at 14:13
  • $\begingroup$ @Feyre. I would do Evaluate[Array[IMGV, 6]] = Table[ImageValue[img, Table[{i, j} ....]], {j, 1111, ...}] instead so that OP can indexed variables that can actually be operated on using Table, Map, etc. $\endgroup$ – march Aug 9 '16 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.