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

CC BY-SA 4.0
2019-10-07T04:38:54.883Z
2019-10-07T04:38:54.883Z
SlimSCSI
<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>

CC BY-SA 4.0
2019-10-09T23:53:38.210Z
2019-10-09T23:53:38.210Z
Rafael
<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>

CC BY-SA 4.0
2019-10-06T13:47:33.953Z
When you downsample, you lose some information. That can't be restored.
Gyan
CC BY-SA 4.0
2022-09-16T08:18:47.957Z
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.
That Realtor Programmer Guy
CC BY-SA 4.0
2022-09-16T08:22:49.550Z
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.
That Realtor Programmer Guy
<video><ffmpeg><encoding><video-quality>
Can ffmpeg downsample pixels perfectly?
HDL
# 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 that downsampling will never be perfect?

**Tags:** video, ffmpeg, encoding, video-quality

> **Comments:**
> **username_1**: When you downsample, you lose some information. That 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

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.


---

### 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 that 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 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.

---

There is NO way to reconstruct the original data from an average, from a downsampled image.

---

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.


---

