This commit is contained in:
Miloslav Ciz 2022-09-06 18:59:19 +02:00
parent 993ef1428c
commit 2da7b0f9f1
2 changed files with 85 additions and 2 deletions

77
bilinear.md Normal file
View file

@ -0,0 +1,77 @@
# Bilinear Interpolation
Bilinear interpolation (also bilinear filtering) is a simple way of creating a smooth transition ([interpolation](interpolation.md)) between [discrete](discrete.md) samples (values) in 2D, it is a [generalization](generalization.md) of [linear interpolation](lerp.md) to 2 dimensions. It is used in many places, popularly e.g. in 3D [computer graphics](graphics.md) for [texture](texture.md) filtering; bilinear interpolation allows to upscale textures to higher resolutions (i.e. compute new pixels between existing pixels) while keeping their look smooth and "non-blocky" (even though blurry). On the scale of quality vs simplicity it is kind of a middle way between a simpler [nearest neighbour](nearest_neighbour.md) interpolation (which creates the "blocky" look) and more complex [bicubic interpolation](bicubic.md) (which uses yet smoother curves but also requires more samples). Bilinear interpolation can further be generalized to [trilinear interpolation](trilinear.md) (in computer graphics trilinear interpolation is used to also additionally interpolate between different levels of a texture's [mipamap](mipamp.md)) and perhaps even bilinear [extrapolation](extrapolation.md). Many frameworks/libraries/engines have bilinear filtering built-in (e.g. `GL_LINEAR` in [OpenGL](ogl.md)).
The principle is simple: first linearly interpolate in one direction (e.g. horizontal), then in the other (vertical). Mathematically the order in which we take the dimensions doesn't matter (but it may matter practically due to rounding errors etc.).
Example: let's say we want to compute the value *x* between the four following given corner values:
```
1 . . . . . . 5
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . x . . .
. . . . . . . .
8 . . . . . . 3
```
Let's say we first interpolate horizontally: we'll compute one value, *a*, on the top (between 1 and 5) and one value, *b*, at the bottom (between 8 and 3). When computing *a* we interpolate between 1 and 5 by the horizontal position of *x* (4/7), so we get *a = 1 + 4/7 * (5 - 1) = 23/7*. Similartly *b = 8 + 4/7 * (3 - 8) = 36/7*. Now we interpolate between *a* and *b* vertically (by the vertical position of *x*, 5/7) to get the final value *x = 23/7 + 5/7 * (36/7 - 23/7) = 226/49 ~= 4.6*. If we first interpolate vertically and then horizontally, we'd get the same result (the value between 1 and 8 would be 6, the value between 5 and 3 would be 25/7 and the final value 226/49 again).
Here is a [C](c.md) code to compute all the inbetween values in the above, using [fixed point](fixed_point.md) (no [float](float.md)):
```
#include <stdio.h>
#define GRID_RESOLUTION 8
int interpolateLinear(int a, int b, int t)
{
return a + (t * (b - a)) / (GRID_RESOLUTION - 1);
}
int interpolateBilinear(int topLeft, int topRight, int bottomLeft, int bottomRight,
int x, int y)
{
#define FPP 16 // we'll use fixed point to prevent rounding errors
#if 1 // switch between the two versions, should give same results:
// horizontal first, then vertical
int a = interpolateLinear(topLeft * FPP,topRight * FPP,x);
int b = interpolateLinear(bottomLeft * FPP,bottomRight * FPP,x);
return interpolateLinear(a,b,y) / FPP;
#else
// vertical first, then horizontal
int a = interpolateLinear(topLeft * FPP,bottomLeft * FPP,y);
int b = interpolateLinear(topRight * FPP,bottomRight * FPP,y);
return interpolateLinear(a,b,x) / FPP;
#endif
}
int main(void)
{
for (int y = 0; y < GRID_RESOLUTION; ++y)
{
for (int x = 0; x < GRID_RESOLUTION; ++x)
printf("%d ",interpolateBilinear(1,5,8,3,x,y));
putchar('\n');
}
return 0;
}
```
The program outputs:
```
1 1 2 2 3 3 4 5
2 2 2 3 3 4 4 5
3 3 3 3 4 4 4 5
4 4 4 4 4 4 4 5
5 5 5 5 5 5 5 4
6 6 6 6 5 5 5 4
7 7 7 6 6 5 5 4
8 8 7 6 6 5 4 3
```

View file

@ -15,7 +15,7 @@ Note that this society is an ideal model, i.e. it can probably not be achieved 1
- **How will society make progress?** Just as it always had: by science, curiosity, necessity etc. - **How will society make progress?** Just as it always had: by science, curiosity, necessity etc.
- **How do you prevent natural human selfish and violent behavior?** Violent and selfish behavior is natural in us just as peaceful and altruistic behavior, we have two sides and which one shows is mostly determined by the conditions in which we live. Nowadays we think people are extremely selfish and violent because we live in society that highly fuels the "evil" side in us, when we're forced to fight for basic living and grow up in a highly competitive environment, it's no surprise most adapt to this and grow up being "dicks". If we're forced to fight for food and brainwashed since birth that "life is a fight", we will be selfish and violent, just as wild wolves are violent while pet dogs whose needs are secured and who were raised peacefully are mostly completely peaceful. If we have abundance and grow up in a society that naturally rejects any violence, we will grow up to solve conflicts peacefully and think of others, just as nowadays we e.g. naturally learn to wear clothes because simply everyone does it and there is little reason not to. If we make resources abundant, there will be no need for selfishness -- do you see anyone stealing air from others out of selfishness? No, because there is no need for it, air is abundant. By changing the environment people live and grow up in we will make 99.99% of people abandon violence and selfish interests (note the remaining natural need for selfishness and competition can be satisfied e.g. with games). - **How do you prevent natural human selfish and violent behavior?** Violent and selfish behavior is natural in us just as peaceful and altruistic behavior, we have two sides and which one shows is mostly determined by the conditions in which we live. Nowadays we think people are extremely selfish and violent because we live in society that highly fuels the "evil" side in us, when we're forced to fight for basic living and grow up in a highly competitive environment, it's no surprise most adapt to this and grow up being "dicks". If we're forced to fight for food and brainwashed since birth that "life is a fight", we will be selfish and violent, just as wild wolves are violent while pet dogs whose needs are secured and who were raised peacefully are mostly completely peaceful. If we have abundance and grow up in a society that naturally rejects any violence, we will grow up to solve conflicts peacefully and think of others, just as nowadays we e.g. naturally learn to wear clothes because simply everyone does it and there is little reason not to. If we make resources abundant, there will be no need for selfishness -- do you see anyone stealing air from others out of selfishness? No, because there is no need for it, air is abundant. By changing the environment people live and grow up in we will make 99.99% of people abandon violence and selfish interests (note the remaining natural need for selfishness and competition can be satisfied e.g. with games).
- **How will you prevent chaos without laws or rules for the people?** We don't say there should be no rules, we are just against complicated written law that no one can even comprehend (even lawyers don't know all laws nowadays) and that has so little in common with morality. Our society works on the basis of moral rules that all stem from the common goal of well being of living beings and that are derived and taught by people themselves -- for example one moral rule that all people would learn would be that money is bad for society (along with the reasons why it is so) and even though there would be no police "enforcing" this rule, the rule would be effective by the fact that absolute majority of people would simply refuse to use money -- in a society where most people know capitalism is bad for them capitalism can't work. Note the importance of the fact that people wouldn't just be taught to memorize such rules as "facts set in stone" (as is our current law), emphasis would be put on people deriving their moral code and understanding how their behavior affects others, people would learn and teach by example. - **How will you prevent chaos without laws or rules for the people?** We don't say there should be no rules, we are just against complicated written law that no one can even comprehend (even lawyers don't know all laws nowadays) and that has so little in common with morality. Our society works on the basis of moral rules that all stem from the common goal of well being of living beings and that are derived and taught by people themselves -- for example one moral rule that all people would learn would be that money is bad for society (along with the reasons why it is so) and even though there would be no police "enforcing" this rule, the rule would be effective by the fact that absolute majority of people would simply refuse to use money -- in a society where most people know capitalism is bad for them capitalism can't work. Note the importance of the fact that people wouldn't just be taught to memorize such rules as "facts set in stone" (as is our current law), emphasis would be put on people deriving their moral code and understanding how their behavior affects others, people would learn and teach by example.
- **How will you prevent criminality such as stealing, murder and mafia organizations?** In a society with abundance for all which works for the good of all criminality simply won't make sense, i.e. we will eliminate criminality by solving the root cause of it, not by curing the symptoms (building prisons etc.). People have no reason to revolt against a system that benefits them or attack other people if there is no conflict between them. Large criminal organizations also cannot exist if most population rejects them, for example there cannot arise a capitalist corporation (or a similar mafia organization) if most population is educated and refuses to engage in capitalism. Of course, we probably won't eliminate criminality 100%, but that's not possible under any other system -- even in your current society with prisons and other punishments there still exist criminality. Of course in practice, until we achieve our ideal, we will likely need to keep some anti-criminality precautions as a necessary evil, but generally we will be able to greatly relax them (reduce police numbers, abandon death penalty, ...) as we move towards the ideal society. For example in an intermediate state of our society dangerous criminals won't be killed but only immobilized and they won't be put in prisons as a punishment but only sent to e.g. a remote island so as to be isolated, without punishing them by restricting their freedom within the island. - **How will you prevent criminality such as stealing, murder and mafia organizations?** In a society with abundance for all which works for the good of all criminality simply won't make sense, i.e. we will eliminate criminality by solving the root cause of it, not by curing the symptoms (building prisons etc.). People have no reason to revolt against a system that benefits them or attack other people if there is no conflict between them. Large criminal organizations also cannot exist if most population rejects them, for example there cannot arise a capitalist corporation (or a similar mafia organization) if most population is educated and refuses to engage in capitalism. In addition to this a more mature, educated and responsible society will naturally minimize genetic predisposition to things such as aggressivity and self interest by natural selection as females will choose to rather have offspring with good people (unlike today), making genes associated with bad behavior go extinct. Of course, we probably won't eliminate criminality 100%, but that's not possible under any other system -- even in your current society with prisons and other punishments there still exist criminality. Of course in practice, until we achieve our ideal, we will likely need to keep some anti-criminality precautions as a necessary evil, but generally we will be able to greatly relax them (reduce police numbers, abandon death penalty, ...) as we move towards the ideal society. For example in an intermediate state of our society dangerous criminals won't be killed but only immobilized and they won't be put in prisons as a punishment but only sent to e.g. a remote island so as to be isolated, without punishing them by restricting their freedom within the island.
- **How will the [economy](economy.md) work without money?** With abundance of resources there will be no money and no trade, resources will be available to anyone who needs them. Various [anarchist](anarchism.md) schools already have proposals for how distribution of resources could work. The [Venus Project](venus_project.md) calls this a [resource based economy](resource_based_economy.md) and proposes using computers and globally placed sensors to collect data and make decisions about where to distribute resources. Resources would be gathered and distributed more locally and cities would be more self sufficient so as to prevent waste and vulnerability of the system, we wouldn't see a huge globalization like nowadays, there is e.g. no need for transporting exotic food all over the whole world to places where there is enough local food available, however anything could be distributed to places where such resources are scarce (e.g. water to deserts). Each community could have food banks and other storage and distribution centers. - **How will the [economy](economy.md) work without money?** With abundance of resources there will be no money and no trade, resources will be available to anyone who needs them. Various [anarchist](anarchism.md) schools already have proposals for how distribution of resources could work. The [Venus Project](venus_project.md) calls this a [resource based economy](resource_based_economy.md) and proposes using computers and globally placed sensors to collect data and make decisions about where to distribute resources. Resources would be gathered and distributed more locally and cities would be more self sufficient so as to prevent waste and vulnerability of the system, we wouldn't see a huge globalization like nowadays, there is e.g. no need for transporting exotic food all over the whole world to places where there is enough local food available, however anything could be distributed to places where such resources are scarce (e.g. water to deserts). Each community could have food banks and other storage and distribution centers.
- **How will you prevent discrimination and racism?** Things such as racism appear when one group of people feels endangered by another group, in a society without social competition these issues will naturally disappear. - **How will you prevent discrimination and racism?** Things such as racism appear when one group of people feels endangered by another group, in a society without social competition these issues will naturally disappear.
- **How will you fulfill the natural need of people for competition?** With sports and other games. Competition of people won't be forbidden, it just won't be mandatory and it won't be the basis of society. - **How will you fulfill the natural need of people for competition?** With sports and other games. Competition of people won't be forbidden, it just won't be mandatory and it won't be the basis of society.
@ -27,4 +27,10 @@ Note that this society is an ideal model, i.e. it can probably not be achieved 1
## How To Implement It ## How To Implement It
TODO This is the hard part, however after successfully setting things in motion it may start to become much easier and eventually even inevitable that the ideal society will be closely approached. However at the moment society seems too spoiled and change of a direction seems very unlikely, it seems more probable that we will destroy ourselves or enslave ourselves forever -- [capitalism](capitalism.md) and similar misdirections of society connected to self-interest, competition, [fascism](fascism.md) etc. pose a huge threat to our endeavor and may ruin it completely, so they need to be strictly opposed, but in a CORRECT way, i.e. not by revolutions and violence but rather by education, offering alternatives and leading examples (i.e. means aligned with our basic values). It has to be stressed that we always need to follow our basic values of nonviolence, love, true rationality etc., resorting to easy ways of violence etc. will only prolong the established cycle of suffering in the society which we are trying to end. Remember, we are not creating a revolution, we aims for a rather slow, nonviolent, voluntary evolutional change.
We already have technology and knowledge to implement our ideal society -- this may have been the most difficult part and it has already been achieved -- that's the good news.
For the next phase education is crucial, we have to spread our ideas further, first among the intellectuals, then to the masses. Unfortunately this phase is still in its infancy, vast majority of intellectuals are completely uneducated in this area -- this we have to change. There are a few that support parts of our plan such as simple technology, nonviolence, not hurting animals etc., but almost no one supports them all, or see the big picture -- we need to unite these people (see also [type A/B fail](fail_ab.md)) to form a small but dedicated community sharing all the proposed ideas. This community will then be able to collaborate on further education, e.g. by creating materials such as books, games, vlogs, giving talks etc.
With this more of the common people should start to jump on the train and support causes such as [universal basic income](ubi.md), [free software](free_software.md) etc., possibly leading to establishment of communities and political parties that will start restricting capitalism and implementing a more socialist society with more freedom and better education, which should further help nurture people better and accelerate the process further. From here on things should become much easier and faster, people will already see the right direction themselves.