Graphics - Laplacian Operator

xiaoxiao2021-03-06  40

There are many factors in the image acquisition, and there are many factors that make the image blur. The image blur is the image being summed, averaging or integral operation, so that the blur is eliminated by opposite calculations, called the image of the image.

Yue wherein the image of a method is the Laplace (Laplacian) operator, Laplace operator is a linear differential operator 2 times, and displacement invariant with isotropic.

For continuous images f (x, y), his Laplas operator is

D ^ 2 f @ ^ 2 f (x, y) / @ x ^ 2 @ ^ ​​2 f (x, y) / @ y ^ 2 editing relationship, left D represents Delta symbol, D ^ 2 means Delta square , is the partial derivative symbol @, @ ^ 2 f (x, y) / @ x ^ 2 is f (x, y) of x 2 sub-partial derivative .... __- !

Processing of g (x, y) = f (x, y) -k * D ^ 2 f is the original target gray gradation i.e. subtracting the Laplacian k times, k is the coefficient

For digital image matrices, the Laplas operator becomes D ^ 2 f (x, y) = dx ^ 2 f (x, y) DY ^ 2 f (x, y) above DX ^ 2 f (x, y) = Dx (Dx f (x, y)) = Dx (f (x 1, y) -f (x, y)) = D f (x 1, y) -D f (x, y) = f (x 1, y) -f (x, y) -f (x, y) f (x-1, y) = f (x 1, y) f (x-1, y) -2 * f (x, y) is obtained similarly Dy ^ 2 f (x, y) = f (x, y 1) f (x, y-1) -2 * f (x, y) Therefore, D ^ 2 f (x, y) = f (x 1, y) f (x-1, y) f (x, y-1) f (x, y 1) -4 * f (x , Y) After the graination, the image is g (x, y) = f (x, y) -d ^ 2 f (x, y)

The following is a 24-bit color image Yue of BMP BCB6 obtained according to the algorithm program // -------------------------------- ---------- BCB6 program

#include #pragma hdrstop # include #include "unit1.h" #include "file1.h" #include

#pragma pack (1)

/ * Program: Graphics - Laplacian image of Rui Author: sboom (Lingch) Date: December 26 * /// BMP file header struct BITMAPFILEHEADER_ {short type; int bfSize; short re1, re2; int OFFBITS;}; // BMP information head Struct Bitmapinfo_ {long size; long width, height; short plan, bitcount; long comp, sizeimg; long xpels, ypels; long buy, important;}; // bmp color meter Struct Color_ {char blue, green, red;}; // ------ BMP color data table which stores correction data to the BCB TColor. TColor * SwitchColor (unsigned char r, unsigned char g, unsigned char b) {tcolor * re = new tcolor; * re = (r | g << 8 | b << 16); * RE = * RE & 0x00FFFFFFFFFFff; Return RE;}

Void xxx () {file * f = fopen ("f: //8.bmp", "rb"); if (f == null) / * determine if the file is opened success * / {showMessage ("File Open Error" Return;} fseek (f, 0, 0); // Move to the beginning

// ---------- Read BMP file head BitmapFileHeader_ * bmph = new bitmapfileHeader_ (); if (FREAD ((Char *) BMPH, SIZEOF (BitmapFileHeader_), 1, f) == null) {showMessage ("File Read Error"); RETURN;}

// ----------- Read BMP information head bitmapinfo_ * bmpi = new bitmapinfo_ (); if (FREAD ((char *) BMPI, SIZEOF (BitmapInfo_), 1, f) == null) { ShowMessage ("File Read Error2"); return; fseek (f, bmph-> offbits, 0); // ---------- display some information form1-> edit1-> text = INTOSTR (BMPH -> bfsize); form1-> edit2-> text = inttostr (bmpi-> width); form1-> edit3-> text = INTOSTR (bmpi-> height); form1-> edit4-> text = INTOSTR (bmpi-> Comp); FORM1-> Edit5-> text = INTOSTR (BMPI-> Used);

INT I, J, K, L, WC, POS; long n = bmph-> bfsize- bmph-> offbits; // Pixel total color_ * Image = new color_ [n]; // bit map matrix color_ * newimage = New color_ [n]; // Filtering bitmap matrix

Fread (image, n * 3, 1, f); // Read bitmap matrix LONG T = 0;

// !!!!!!!!!!!!!!! Let's take a handling !!!!!!!!!!!!!!!!!!!!!!! for (i = 1; i width; i ) // The last line can not seek gradient {t = image [i 1] .red image [i-1] .red image [i bmpi-> width- 1] .red image [i bmpi-> width 1] .RED-4 * image [i] .red; newimage [i] .RED = image [i] .red-t;

T = image [i 1] .Green image [i-1] .green image [i bmpi-> width-1] .Green image [i bmpi-> width 1] .green-4 * Image [i] .Green; newimage [i] .green = image [i] .green-t; t = image [i 1] .boe image [i-1] .boe image [i bmpi-> Width-1] .boe image [i bmpi-> width 1] .boe-4 * image [i] .boe; newimage [i] .blue = image [i] .boe-t;} //! !!!!!!!!!!!!!! Take the end !!!!!!!!!!!!!!!!!!!!!!!! / / ----- ---------- Display graphic color_ color; tcolor * tc; if (bmpi-> width% 4 == 0) // ----------- Because BMP images 4 bytes Align WC = BMPI-> Width / 4 * 4; ELSE WC = (BMPI-> Width / 4 1) * 4;

POS = 0; for (i = 0; i height; i ) {for (j = 0; j Canvas-> Pixels [10 J] [600-i] = * TC; // ------ New Graph Color = NewImage [POS]; tc = switchcolor (color.red, color.green, color.blue); form1-> canvas-> pixels [400 j] [600-i] = * TC; POS ;}} fclose (f) }

// ------------------------------------------ in a 24-bit After the BMP color image is discovered, the grayscale change is a flat-plane area to be compared to Photoshop, but the grayscale mutation edge region will become very prominent, almost a edge extraction. In my image, the scenes on the stage are the most natural, while the stage is too high-out along the stage, and the edges become bright colors along the line.

转载请注明原文地址:https://www.9cbs.com/read-76438.html

New Post(0)