I want to extract/cut out a part of an image. Since my mask is not rectangular I want to set pixels that are not masked to zero (black). My current approach is something like this:
img = Import["path/to/image/image.jpg"];
{x, y, temp} = Dimensions@ImageData[img];
center = {100, 100};
radius = 30;
pixels =
Select[Flatten[Table[{i, j}, {i, 0, x}, {j, 0, y}], 1],
(center[[1]] - #[[1]])^2 + (center[[1]] - #[[2]])^2 > radius^2 &];
ReplaceImageValue[img, Map[# -> 0 &, pixels]]
Even though this works, it is extremely slow for large images. Is there any way to speed this up?