Image Dissolving in C#

CoderSource.net
Image Dissolving in C# - Article by asif
Rating:

Date: 6/13/2005 6:26:51 PM

Image Dissolving in C#

What is Image Dissolving? Basic DETAILS...

Image dissolving is based on Alpha Blending. Lets have a look on Alpha Blending first.

Alpha blending is a convex combination of two colors allowing for transparency effects in computer graphics. The value of alpha in the color code ranges from 0.0 to 1.0, where 0.0 represents a fully transparent color, and 1.0 represents a fully opaque color.

The value of the resulting color when color Value1 is drawn over a background of color Value0 is given by:

Value = Image1(1.0 − alpha) + Image2(alpha)

The alpha component is used to blend to red, green and blue components equally, as in 32-bit RGBA, or, alternatively, there are three alpha values specified corresponding to each of the primary colors for spectral color filtering.

Alpha blending is the process of combining a translucent foreground color with a background color, thereby producing a new blended color. The degree of the foreground color's translucency may range from completely transparent to completely opaque. If the foreground color is completely transparent, the blended color will be the background color. Conversely, if it is completely opaque, the blended color will be the foreground color. Of course, the translucency can range between these extremes, in which case the blended color is computed as a weighted average of the foreground and background colors. Fastgraph provides alpha blending functions that work on RGB color values, on direct color bitmaps, and on direct color virtual buffers.

  • In texturing, it will be used for blending color components
  • In RGBA texturing, the texture's alpha value is sometimes used to specify blending
  • In texturing, sometimes the texture's RGB color will be used as 3 alpha values to give spectral color filtering
  • Where Alpha Blending is Used:

    Alpha blending can also be used for drop shadows, these are usually seen on menus and cursors.

    Basic Algorithm Of Image Averaging

    Using alpha blending, one image was dissolved into another. Essentially, the value of each pixel in the resulting image is a weighted average of the pixels in the two originals. The weight (usually called alpha) varies over time. This technique was applied to each of red, green, and blue. Several output frames were generated with gradually increasing values of alpha. Here is how it works really:

    for(double alpha=1.0;alpha>0.0;alpha-=(1.0/((double)(nSteps))))

    {

    byte* ptr1 = ( byte* )data1.Scan0;

    byte* ptr2 = ( byte* )data2.Scan0;

    byte* ptr3 = ( byte* )data3.Scan0;

    for( int i = 0 ; i < height ; i ++ )

    {

    for( int j = 0 ; j < width * 3 ; j ++ )

    {

    ptr3[ 0 ] = ( byte )(alpha*ptr1[0]+(1-alpha)*ptr2[0]);

     

    Guidelines for Use

    To understand the working of the Image Averaging, take the example of the following images:

    the Resultant Image Obtained by the Averaging of the above images is as:

    Sample Project

    Please Review other articles based on Logical Operators to get the better understanding of the project. The application seems to be in this GUI.

    Results:

    A smooth transition from the first image to the second is seen in the resultant image..

    The project is a part of the series of the image processing articles written just for the prosperity and help for the students searching for Image Processing free stuff.

    Attachments:

       Project Files: Dissolving_Image_CSharp.zip

    You Can Rate this Article, if you are Logged In      
     

    More Links from CoderSource.net:

     
    Refer to a Friend:

    Your Details:

    Name:     e-mail:

    Friend Details:

    Name:    e-mail:    


    MENU
    Home
    MFC 
    C++
    .Net
    WIN32
    Programming
    Forum
    My Articles
    Add to Google
    Add to My Yahoo!
    Welcome to Codersource.Net Login | Register | Faq  

    SEARCH
    Google
     

    NOTES:


    Thanks for visiting our CoderSource.net. This site will be improved with more articles. Interested visitors can also submit their articles through the Submit Article link.Your article will also be published after due consideration by the editor. 

    © Copyright 2003. All rights on content reserved by CoderSource.net. Contact    About Us