简体   繁体   中英

when resize my photo, what should i use function among floor, round, ceil in Matlab?

when resize my photo, what should i use function among floor, round, ceil in Matlab?

myimg (256, 256)

when scalefactor is 0.8

256 * 0.8 = 204.8

and then, scaled size of myimg (204.8 , 204.8)

in this case, ceil(204.8) or floor(204.8) or round(204.8)

what should I do?

As the previous commenter outlined it depends on what you need and the use case. Just for anyone looking for functional clarity:

  1. ceil() : Returns the closest integer greater than the input value.
  2. round() : Rounds the input to the closest integer (decimals greater than 0.5 round-up).
  3. floor() : Returns the closest integer lesser than the input value.

Example:

ceil(204.8) → 205

round(204.8) → 205 and round(204.2) → 204

floor(204.8) → 204

Extension:

In this case, if your criteria required an image of at least 80% of the original I would use ceil() . If you require an image size of less than 80% of the original then floor() would best suit. In any other case where the scenario is flexible round() is a good option which will give the closest image resizing down to 80%.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM