数学艺术模式 [英] Math Art Patterns

查看:51
本文介绍了数学艺术模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经通过C#中的SetPixel通过使用一些公式制作了一些数学图像.
问题在于这些图像模糊在一定程度上是模糊的.
通过进行一些量化,我使它变得更好.但是仍然不是最喜欢的图像.
有谁知道所谓的作品?
如何改善这类图像?
有谁知道关于这些图像之王的文章吗?



Hi,
I have made some mathematical images by using some formula through SetPixel in C#.
The problem is that these images are blur to some extend.
By doing some quantizing I have made it better. But still it is not the favorite image that can be.
Does anyone know what is called such a work?
How to improve these kind of images?
Does anyone know any article about these king of images?



public int ColorQuantize(double color,int step)
{
    return ((((int)color) / step)+1) * step;
}

public void RGB(int i, int j, double x, double y, ref double r, ref double g, ref double b)
{
    r = ColorQuantize(Math.Sqrt(Math.Abs(Math.Atan(x / y) * Math.Sin(x * Math.PI - y)) * 2 / Math.PI) * 256, 40);
    g = ColorQuantize((Math.Tan(x) * Math.Tan(x-y) + Math.Tan(y*x) * Math.Tan(y)) * 256, 40);
    b = ColorQuantize(Math.Cos(Math.Sqrt(Math.Abs(x * y)) * 7-Math.Tan(x*x+y*y)) * 256, 40);
}

public Bitmap myImage()
{
    double dimX, dimY;
    dimX = pictureBox1.Size.Width;
    dimY = pictureBox1.Size.Height;
    Bitmap bmp = new Bitmap((int)dimX, (int)dimY);
    int HalfX = (int)(dimX / 2), HalfY = (int)(dimY / 2);
    for (int i = 0; i < dimX; i++)
        for (int j = 0; j < dimY; j++)
        {
            double r = 0, g = 0, b = 0;
            int X = i - HalfX, Y = j - HalfY;
            RGB(X, Y, X / (dimX / 2), Y / (dimY / 2), ref r, ref  g, ref  b);
            r = (int)(Math.Abs(r) % 256);
            g = (int)(Math.Abs(g) % 256);
            b = (int)(Math.Abs(b) % 256);
            bmp.SetPixel(i, j, Color.FromArgb((int)r, (int)g, (int)b));
        }
    return bmp;
}

推荐答案

老实说,初稿看起来并不那么糟糕.问题是您没有遵循良好成像的基本原则之一,而总是抗锯齿.如果您在一个块上评估函数,然后对结果求平均,则效果会更好.例如,对于每个像素,WPF中的笔刷平均为64(如果我没记错的话)的网格.

您还可以使图像大于实际所需的大小,然后将其缩小.请记住,您不需要执行代码中的所有操作.尝试使用Photoshop转换图像的速度要快得多.较小的.8像素高斯模糊可让您的大部分图像变得更好,右上角和左下角的问题更大.

我希望这有帮助.

To be honest it does not look that bad for a first draft. The problem is that you are not folowing one of the fundamental tennants of nice imaging, always anti-alias. If you evaluate your function over a block and then average the result it should look better. For example the brushes in WPF average over grid of 64 (if I recall correctly ) for each pixel.

You could also make the image larger than you really want and then reduce it. Remember that you do not need to do everything in code. It is much faster to experiment with how you want to transform your image using photoshop. A small .8 pixel gaussian blur makes the majority of your image better, the upper right and lower left corners are more problematic.

I hope this helps.

Ken


这篇关于数学艺术模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆