박재환
박재환

Reputation: 3

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?

Upvotes: 0

Views: 196

Answers (1)

MichaelTr7
MichaelTr7

Reputation: 4767

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%.

Upvotes: 0

Related Questions