Answers.Body: <p>That violates the rules of information theory. Look into the work of Claude Shannon if you wish to understand why what you are asking is mathematically impossible. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-07T04:38:54.883Z
Answers.LastActivityDate: 2019-10-07T04:38:54.883Z
Answers.UserDisplayName: SlimSCSI
Answers.Body: <p>The information on an image is not made of rubber, you can not shrink and expand an image that way.</p>
  
  <p><strong>Downsampling is re-sampling</strong>. Making new data out of the initial information. Normally it is based on an average.</p>
  
  <p>One example.</p>
  
  <p>I make a poll on how many times a week do people eat icecream in summer.</p>
  
  <ul>
  <li>Jane 2</li>
  <li>Jack 2</li>
  <li>Sue 3</li>
  <li>JohnTheIcecreamEater 7</li>
  </ul>
  
  <p>The average is 3.5 icecreams per person... average.</p>
  
  <p>If I tell you that the average of lemonade drinks on the same week is 2, you have no idea what the original values are. You do not know if there is a JaneLemonadeDrinker or not.</p>
  
  <hr>
  
  <p>There is NO way to reconstruct the original data from an average, from a downsampled image.</p>
  
  <hr>
  
  <p>There are some algorithms that can assume a bit of new data and invent it. But having the original data is way better for detailed information.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-09T23:53:38.210Z
Answers.LastActivityDate: 2019-10-09T23:53:38.210Z
Answers.UserDisplayName: Rafael
Body: <p>I've tried all the swsflags options and figure the answer is no, but it can't hurt to ask just in case.  For example: downsample from 1920x1080 to 960x540, then upsample back to 1080 using the neighbor flag to recreate a perfect copy of the original 1080 image.  Neighbor comes very close but there seems to be some color shifting happening in the downsample.  Can another filter accomplish this, or is it simply the nature of the beast that downsampling will never be perfect?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-06T13:47:33.953Z
Comments.Text: When you downsample, you lose some information. That can't be restored.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-16T08:18:47.957Z
Comments.Text: rather than downsampling, potentially lossless formats like PNG -- to a lesser extent "mixed-loss" formats like JPEG, turn portions of a raster to vectors -- or at least simple patterns. --- i.e. "Dithering" is basically a method of losing some information on purpose to squeeze a region into a similar (but simpler to compress) gradient. When you have a graphic on a solid 1 color background, --- PNG compresses the repeating colors into a data structure rather than storing a flat pixel array. These are ways to reduce or prevent loss while reducing filesize. Downsampling always has loss though.
Comments.UserDisplayName: That Realtor Programmer Guy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-16T08:22:49.550Z
Comments.Text: TL;DR: Rather than downsampling; you may really want to ask around about lossless compression if file size is a goal. If visuals are the goal there are two other major factors: maintaining aspect ratio and aliasing.
Comments.UserDisplayName: That Realtor Programmer Guy
Tags: <video><ffmpeg><encoding><video-quality>
Title: Can ffmpeg downsample pixels perfectly?
UserDisplayName: HDL
ThreadText: # Can ffmpeg downsample pixels perfectly?
  
  (Asked by: username_0 on 2019-10-06)
  
  I've tried all the swsflags options and figure the answer is no, but it can't hurt to ask just in case. For example: downsample from 1920x1080 to 960x540, then upsample back to 1080 using the neighbor flag to recreate a perfect copy of the original 1080 image. Neighbor comes very close but there seems to be some color shifting happening in the downsample. Can another filter accomplish this, or is it simply the nature of the beast username_2 downsampling will never be perfect?
  
  **Tags:** video, ffmpeg, encoding, video-quality
  
  > **Comments:**
  > **username_1**: When you downsample, you lose some information. username_2 can't be restored.  
  > **username_2**: rather than downsampling, potentially lossless formats like PNG -- to a lesser extent "mixed-loss" formats like JPEG, turn portions of a raster to vectors -- or at least simple patterns. --- i.e. "Dithering" is basically a method of losing some information on purpose to squeeze a region into a similar (but simpler to compress) gradient. When you have a graphic on a solid 1 color background, --- PNG compresses the repeating colors into a data structure rather than storing a flat pixel array. These are ways to reduce or prevent loss while reducing filesize. Downsampling always has loss though.  
  > **username_2**: TL;DR: Rather than downsampling; you may really want to ask around about lossless compression if file size is a goal. If visuals are the goal there are two other major factors: maintaining aspect ratio and aliasing.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2019-10-07. Score: 1
  
  username_2 violates the rules of information theory. Look into the work of Claude Shannon if you wish to understand why what you are asking is mathematically impossible.
  
  
  ---
  
  ### Answer by username_4 on 2019-10-09. Score: 1
  
  The information on an image is not made of rubber, you can not shrink and expand an image username_2 way.
  
  **Downsampling is re-sampling**. Making new data out of the initial information. Normally it is based on an average.
  
  One example.
  
  I make a poll on how many times a week do people eat icecream in summer.
  
  * Jane 2
  * Jack 2
  * Sue 3
  * JohnTheIcecreamEater 7
  
  The average is 3.5 icecreams per person... average.
  
  If I tell you username_2 the average of lemonade drinks on the same week is 2, you have no idea what the original values are. You do not know if there is a JaneLemonadeDrinker or not.
  
  ---
  
  There is NO way to reconstruct the original data from an average, from a downsampled image.
  
  ---
  
  There are some algorithms username_2 can assume a bit of new data and invent it. But having the original data is way better for detailed information.
  
  
  ---
  
  