Basic of Digital Image Processing

Source: Internet
Author: User
Tags color representation

As we all know, most of the information obtained by humans comes from vision. Humans observe the world with their own eyes and discover the world. Images are a vivid description of the similarity between objective objects and scenes. The images currently seen in computers, networks, and electronic products are digital images. Before explaining image processing, you must have some basic knowledge about image processing. The following describes some common basic knowledge about image processing.

Pixels

Pixels are the basic encoding of the basic pigment and its gray scale. The digital image we see is composed of a two-dimensional Pixel matrix. Pixels are usually stored in 24-Bit mode in three bytes. For example, 16-23 bits indicate the red (r) component, and 8-15 bits indicate the green (g) component, 0-7 bits represent the blue (B) component. For details, see the color representation in "Computer Color Model RGB" below.

The real world is 3D, but the images we take from the real world are 2D information. An image can be defined as a two-dimensional function f (x, y). (x, y) is the coordinate of points in two-dimensional space. F (x, y) is the coordinate value corresponding to the point, that is, the pixel.


When the image size is in pixels, each 1 cm is equal to 28 pixels. For example, a 15*15 cm length image is equal to the length of 420*420 pixels.

The number of different colors a pixel can express depends on the bit per pixel (BPP ). For example, 8bpp [2 ^ 8 = 256 colors, grayscale images], 16bpp [2 ^ 16 = 65536 colors, referred to as high color], 24 BPPS [2 ^ 24 = 16777216 colors, it is called true color].

Resolution

The total number of pixels of an image is called the image resolution. Because images are usually represented by matrices, resolution is commonly used. M * n indicates the number of rows (that is, the number of pixels contained in a column) and M indicates the number of columns (that is, the number of pixels contained in a row ). For example, 640*480 indicates that the length and width of the image are 640 and 480 respectively, and the total pixel is 640*480 = 307200 (0.3 million resolution described in the camera), 800*600, the length and width of the image are 800 and 600 respectively, and the total pixel is 800*600 = 480000 (the 0.5 million resolution described in the camera ).

Computer Color Model Machine RGB

A color model is a digital model, or a way to record the color of an image. The RGB model, CMYK model, HSL model, and LAB color model are available. The most common model is the RGB model.

RGB

As we all know, almost all colors in the world can be formed by different proportions of red, green and blue. red, green and blue are called the three primary colors.

But how does he represent it on a computer?

In the computer, the colors R, G, and B are quantified to 0-256 levels. In this way, the color image has 256*256*256 = 16777216 colors, which are called full-color nimage or true-color image ).

Each pixel in an image stores a color value, and each color is composed of three colors: RGB. Therefore, the color can be represented by three-dimensional coordinates of three colors: R, G, and B. For example:

According to the composition principle of image color, an image can be divided into three gray-scale images: R, G, and G. For example:

Source image 1 fig red

Figure ‑ green figure ‑ blue

Algorithm code implementation (Java): See Appendix 1 below

Note:When the R, G, and B colors of each pixel of an image are the same, it is a non-color grayscale image.For example:


Figure ‑ gray

Algorithm code implementation (Java): See Appendix 2 below

Appendix 1: Algorithms for decomposing images into R, G, and B gray images

/*** Split the image into three gray images: R, G, and B */public static void analysergb () {outputstream output = NULL; try {// read imagebufferedimage IMG = ImageIO. read (new file ("F: \ image processing \ figure 1.jpg"); int imagetype = IMG. getType (); int W = IMG. getwidth (); int H = IMG. getheight (); int startx = 0; int starty = 0; int offset = 0; int scansize = W; int dd = W-startx; int HH = H-starty; int X0 = W/2; int Y0 = H/2; // system. out. PR Intln ("DD:" + dd + "HH:" + HH); // an array of RGB, storing pixels, use a one-dimensional array to represent the two-dimensional image pixel array int [] rgbarray = new int [Offset + HH * scansize + DD]; // newarray saves the processed pixel int [] newarray = new int [Offset + HH * scansize + DD]; IMG. getrgb (startx, starty, W, H, rgbarray, offset, scansize); int RGB = rgbarray [Offset + (y0-starty) * scansize + (x0-startx)]; color c = new color (RGB); // system. out. println ("rgb of the middle pixel:" + C); For (INT I = 0; I 

Appendix 2: Algorithms for splitting images into black and white images
/*** Break down an image into a black/white image */public static void grayimage () {outputstream output = NULL; try {// read imagebufferedimage IMG = ImageIO. read (new file ("F: \ image processing \ baboom.jpg"); int imagetype = IMG. getType (); int W = IMG. getwidth (); int H = IMG. getheight (); int startx = 0; int starty = 0; int offset = 0; int scansize = W; int dd = W-startx; int HH = H-starty; int X0 = W/2; int Y0 = H/2; system. out. println ("DD:" + dd + "HH:" + HH); // RGB array, save pixels, use a one-dimensional array to represent the two-dimensional image pixel array int [] rgbarray = new int [Offset + HH * scansize + DD]; // newarray saves the processed pixel int [] newarray = new int [Offset + HH * scansize + DD]; IMG. getrgb (startx, starty, W, H, rgbarray, offset, scansize); int RGB = rgbarray [Offset + (y0-starty) * scansize + (x0-startx)]; color c = new color (RGB); system. out. println ("rgb of the middle pixel:" + C + "" + C. getrgb (); For (INT I = 0; I 

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.