Gaussian fuzzy algorithm c source code.

Source: Internet
Author: User

Spgui (simple powerfull Graphics User Interface) is a simple and powerful embedded graphics development system. It mainly provides a tool set for developing embedded Linux graphic window applications. She has beautiful and friendly graphical controls, image-oriented programming interfaces, multi-platform portability, and other features. spgui is a graphic Window application designed to run on embedded devices, PCs, and workstation platforms, provides a complete development platform. Her core is to provide a resource library and a compilation link environment for the application. developers can use the resources and environment provided by spgui to develop their own applications. The resources provided by spgui for Application designers include: Embedded graphics engine, graphical controls, database engine, underlying driver encapsulation, common data structure encapsulation, and Chinese support.

Spgui is highly portable at the source code level,

At present, after my own efforts have been transplanted to Windows XP to use VC 2005 for Development (can be called a simulator), the developed program only needs to be compiled on the embedded platform to run.

The following functions are also extended.

Images can be PNG, GIF, BMP, or JPG.

Font management FreeType vector font library, fnt Font Library

Zip Compression

Script XML expat

Window framework: EMS UI (updated in the next article)

Help: 124736442@qq.com

Let's get down to the truth.

First look

Before

After

Gaussian fuzzy algorithm C source code.

The color information is 565 can be modified to rgb888 argb and grayscale processing.

//---------------------------------------------------------------------------------
// 124736442@qq.com
//
//
// Smooth (de-noise) and sharpen the image
//
//
//---------------------------------------------------------------------------------
# Include <mach/effect. h>
# Include <mach/datatype. h>

Enum EFFECT_TYPE {
SMOOTH_BOX = 0,
SMOOTH_GAUSS,
SHARPEN_LL
};
// Template array

SINT32 Smooth_Box [10] = {1, 1, 1, 1, 1, 3 };
SINT32 Smooth_Gauss [10] = {1, 2, 1, 2, 2, 1, 4 };
SINT32 Sharpen_Laplacian [10] = {-1,-1,-1,-,-1,-1,-1 };

SINT32 Bitmap_SmoothDeal (spBitmap_t * p, spRect_t * rect, int type)
{
SINT32 * tEffect = NULL;
UINT8 * stpos;
UINT16 * pbg;
Int r, g, B, Index, row, col;
Int x; int y;
UINT8 r1, g1, b1;
UINT32 colorref;
UINT32 sumcol;
Switch (type)
{
Case SMOOTH_BOX:
TEffect = Smooth_Box;
Break;
Case SMOOTH_GAUSS:
TEffect = Smooth_Gauss;
Break;
Case SHARPEN_LL:
TEffect = Sharpen_Laplacian;
Break;
Default:
Return SP_FAIL;
}

Stpos = (UINT8 *) (p-> pData + (rect-> x * p-> bpl/p-> width + rect-> y * p-> bpl ));
For (y = 1; y <rect-> height-1; y ++)
For (x = 1; x <rect-> width-1; x ++)
{

R = 0, g = 0, B = 0;
Index = 0;
Sumcol = 0;
For (col =-1; col <= 1; col ++)
{
Pbg = (UINT16 *) (stpos + (y + col) * p-> bpl );
For (row =-1; row <= 1; row ++)
{
Colorref = pbg [x + row];
RGB_FROM_RGB565 (colorref, r1, g1, b1 );
R + = r1 * tEffect [Index];
G + = g1 * tEffect [Index];
B + = b1 * tEffect [Index];
Index ++;
}
}
R >>= tEffect [Index]; // adjust the brightness.
G >>= tEffect [Index];
B >>= tEffect [Index];

RGB565_FROM_RGB (colorref, r, g, B );
Pbg [x] = (UINT16) colorref;
}

Return SP_ OK;
}

SINT32 effect_do (spBitmap_t * image, spRect_t * rect, SINT32 type)
{
SpRect_t tRect;
If (image = NULL)
Return SP_FAIL;
If (rect = NULL ){
TRect. x = tRect. y = 0;
TRect. width = image-> width;
TRect. height = image-> height;
}
Else
TRect = * rect;
// Check rect

TRect. x = tRect. x <0? 0: tRect. x;
TRect. y = tRect. y <0? 0: tRect. y;
TRect. width = tRect. width> image-> width? Image-> width: tRect. width;
TRect. height = tRect. height> image-> height? Image-> height: tRect. height;

// Do effect
Switch (type)
{
Case SMOOTH_BOX:
Case SMOOTH_GAUSS:
Case SHARPEN_LL:
// Return SP_ OK;
Bitmap_SmoothDeal (image, & tRect, type );
Break;
}
Return SP_ OK;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.