Skip to main content
edited tags
Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Tweeted twitter.com/StackMma/status/1031194430819246081
edited tags
Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
minor
Source Link
Carl Woll
  • 131.7k
  • 6
  • 246
  • 359

This question is related to this. Consider an array array1array as

 array = ImageData[RandomImage[10, 10]];

And the indices of the desired values are

desired = {{1, 3}, {1, 4}, {1, 5}, {1, 6}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, 
  {3, 3}, {3, 4}, {3, 5}, {3, 6}, {4, 3}, {4, 4}, {4, 5}, {4, 6}, {5, 
  2}, {5, 3}, {5, 4}, {5, 5}, {5, 6}, {6, 2}, {6, 3}, {6, 4}, {6, 
  5}, {6, 6}, {7, 3}, {7, 4}, {7, 5}, {7, 6}, {8, 3}, {8, 4}, {8, 
  5}, {8, 6}};

The desired values can be found (following the answer to the earlier question) through

val = Extract[array,desired];

Now I have another array array2 of same dimensions of array1 and I wish to assign the values in val to the desired postions desired of array2.

I tried the following one:

array2[[##]] & @@@ desired = val;

However, this does not work.

How can I do this?

This question is related to this. Consider an array array1 as

 array = ImageData[RandomImage[10, 10]];

And the indices of the desired values are

desired = {{1, 3}, {1, 4}, {1, 5}, {1, 6}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, 
  {3, 3}, {3, 4}, {3, 5}, {3, 6}, {4, 3}, {4, 4}, {4, 5}, {4, 6}, {5, 
  2}, {5, 3}, {5, 4}, {5, 5}, {5, 6}, {6, 2}, {6, 3}, {6, 4}, {6, 
  5}, {6, 6}, {7, 3}, {7, 4}, {7, 5}, {7, 6}, {8, 3}, {8, 4}, {8, 
  5}, {8, 6}};

The desired values can be found (following the answer to the earlier question) through

val = Extract[array,desired];

Now I have another array array2 of same dimensions of array1 and I wish to assign the values in val to the desired postions desired of array2.

I tried the following one:

array2[[##]] & @@@ desired = val;

However, this does not work.

How can I do this?

This question is related to this. Consider an array array as

 array = ImageData[RandomImage[10, 10]];

And the indices of the desired values are

desired = {{1, 3}, {1, 4}, {1, 5}, {1, 6}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, 
  {3, 3}, {3, 4}, {3, 5}, {3, 6}, {4, 3}, {4, 4}, {4, 5}, {4, 6}, {5, 
  2}, {5, 3}, {5, 4}, {5, 5}, {5, 6}, {6, 2}, {6, 3}, {6, 4}, {6, 
  5}, {6, 6}, {7, 3}, {7, 4}, {7, 5}, {7, 6}, {8, 3}, {8, 4}, {8, 
  5}, {8, 6}};

The desired values can be found (following the answer to the earlier question) through

val = Extract[array,desired];

Now I have another array array2 of same dimensions of array1 and I wish to assign the values in val to the desired postions desired of array2.

I tried the following one:

array2[[##]] & @@@ desired = val;

However, this does not work.

How can I do this?

Bumped by Community user
Bumped by Community user
Source Link
user36426
  • 3.4k
  • 11
  • 30
Loading