Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
}
Posted

1 solution

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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900