1
$\begingroup$

I would like to take in an array of images as input, and then call the ColorSeparate function on each of them, and retrieve this as output.

So far I have the following :

test1 = Import[
  "C:\\filelocation\\*.jpg"]
Scan[ColorSeparate, test1]

This correctly obtains the array of images, however the Scan does not appear to produce an output. Have I approached this in the wrong way, and how might I be able to get output from this?

$\endgroup$
4
$\begingroup$

From the documentation of Scan:

Scan[f,expr] discards the results of applying f to the subexpressions in expr. Unlike Map, Scan does not build up a new expression to return.

So what you actually want is

Map[ColorSeparate,test1]

or

ColorSeparate/@test1
$\endgroup$
2
$\begingroup$

Like Graumagier has said, the function Scan does not return.

So if you want to see the "Scan", you must print it out since there is no return:

Scan[Print[ColorSeparate[#]] &, test1]    

Or otherwise, you want to get a returned value, then use Map.

Map[ColorSeparate, test1]
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.