1
$\begingroup$

The image is generated by the code below:

img = ExampleData[{"TestImage", "House"}];
ImageTransformation[img, If[Norm[# - 0.5] < 0.5, #, {-0.1, -0.1}] &]

enter image description here

How can I set the background from black to white, and it will only be applied on the region out of the disk?

$\endgroup$
  • 1
    $\begingroup$ add the option Padding -> 1? $\endgroup$ – kglr Dec 18 '18 at 2:46
  • $\begingroup$ That works! thanks! $\endgroup$ – leon365 Dec 18 '18 at 2:47
2
$\begingroup$
ImageTransformation[img, If[Norm[# - 0.5] < 0.5, #, {-0.1, -0.1}] &, 
 Background -> White, Masking -> All]

enter image description here

Alternatively,

ImageTransformation[img, If[Norm[# - 0.5] < 0.5, #, {-0.1, -0.1}] &, Padding-> 1]

enter image description here

$\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.