Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.9K Views
|
5 Replies
|
14 Total Likes
View groups...
Share
Share this post:

Crop a circle region from an image faster?

Posted 6 years ago
POSTED BY: Shaohui Yin
5 Replies

Try

im Image@DiskMatrix[ImageDimensions[im]/2, ImageDimensions[im]]

assuming im = Image[img].

POSTED BY: Szabolcs Horvát

This most likely is the optimal solution! Somewhere in the fog I was aware of DiskMatrix, but one is always prone to "invent the wheel twice" ...

POSTED BY: Henrik Schachner

Another example you can try:

POSTED BY: Shenghui Yang

I did not do any timings, but maybe this is pointing into the right direction. I am applying a mask made out of a graphics:

img = Image@
   Abs[Cos[\[Pi]^2 Outer[Plus, Range[-1, 1, 0.002]^2, 
       2 Range[-1, 1, 0.002]^2]]];

dims = ImageDimensions[img];
mask = Image[
   Graphics[{White, Disk[{0, 0}, Min[dims]/2]}, Background -> Black, 
    PlotRangePadding -> None], ImageSize -> dims];

imgCrop = img mask
POSTED BY: Henrik Schachner
Posted 6 years ago

Thank you. It is forty times faster than my method.

POSTED BY: Shaohui Yin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard