1. Technical Field
Embodiments of the present disclosure relate to image processing technology, and particularly to an image conversion system and method for converting a two-dimensional image into a three-dimensional image.
2. Description of Related Art
Currently, image measurement machines are widely used in manufacturing to capture images of manufactured parts. However, the images captured by the image measurement machines are usually two-dimensional, and no depth information is conveyed in the images.
In general, the word “module,” as used herein, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a program language. In one embodiment, the program language may be Java or C. One or more software instructions in the modules may be embedded in firmware, such as an EPROM. The modules described herein may be implemented as either software and/or hardware modules and may be stored in any type of computer-readable medium or other storage device.
The read module 200 reads image data of a two-dimensional image from the storage system 12, and displays the two-dimensional image on the display device 14.
The determination module 210 determines an image format of the two-dimensional image according to the image format information, and determines an image size according to the image size information. In one embodiment, each pixel value may occupy different bits of the storage system 12 if the two-dimensional image is in different image formats. For example, if the two-dimensional image is in an 8-bit format, each pixel value may occupy 8 bits (one byte) of the storage system 12. If the two-dimensional image is in a 16-bit format, each pixel value may occupy 16 bits (two bytes) of the storage system 12.
The image size of the two-dimensional image may include a width and a height in pixels. In one example of a 60×80 two-dimensional image, the width is 60 pixels, and the height is 80 pixels.
The determination module 210 further determines a pixel value of each pixel in the two-dimensional image according to the pixel information and the image format, and determines pixel coordinates of each pixel in the two-dimensional image according to the image size. In one embodiment of a two-dimensional image in an 8-bit format, the determination module 210 may retrieve an 8-bit pixel value, such as “10001010”, for each pixel in the two-dimensional image from the pixel information.
The pixel coordinates of each pixel in the two-dimensional image may be determined according to a column number and a row number of the pixel in the two-dimensional image.
The calculation module 220 calculates a gray value of each pixel in the two-dimensional image according to the pixel value of the pixel. In one embodiment of an RGB two-dimensional image, the pixel value of each pixel consists of a red component value, a green component value, and a blue component value. The calculation module 220 may apply a conversion formula, such as gray value=R*0.3+G*0.59+B*0.11, to calculate the gray value, wherein R, G, and B respectively represent a red component value, a green component value, and a blue component value of a pixel in the two-dimensional image.
The generation module 230 generates a three-dimensional point for each pixel in the two-dimensional image according to the pixel coordinates and the gray value of the pixel. In one example, if the pixel coordinates of a pixel are (5, 9) and a gray value of the pixel is 45, a three-dimensional point (5, 9, 45) is generated for the pixel. The generation module 230 further generates a three-dimensional mesh by connecting all the generated three-dimensional points. In one example of a 60×80 two-dimensional image, the generation module 230 generates 4800 three-dimensional points, and generates a three-dimensional mesh by connecting the 4800 three-dimensional points. The three-dimensional mesh is a three-dimensional model derived from the two-dimensional image.
The decoration module 240 decorates the three-dimensional mesh by adding surface characteristics to the three-dimensional mesh. The surface characteristics may include varied surface details such as color, texture, transparency, wrinkles, and pleats. In one embodiment, the decoration module 240 adds the surface characteristics to the three-dimensional mesh using a texture mapping method and/or a shading method.
The display module 250 displays the decorated three-dimensional mesh on the display device 14.
In block S301, the read module 200 reads image data of a two-dimensional image from the storage system 12, and displays the two-dimensional image on the display device 14. As mentioned above, the image data may include image format information, image size information, and pixel values.
In block S302, the determination module 210 determines an image format of the two-dimensional image according to the image format information, and determines an image size according to the image size information. In one embodiment, the two-dimensional image is an RGB (red, green, blue) image. The image format of the RGB image may include an 8-bit format, a 16-bit format, a 24-bit format, and a 32-bit format. Each pixel value may occupy different bits of the storage system 12 if the two-dimensional image is in different image formats. In one example, each pixel value may occupy 8 bits (one byte) of the storage system 12 if the two-dimensional image is in an 8-bit format. In another example, each pixel value may occupy 32 bits (four bytes) of the storage system 12 if the two-dimensional image is in a 32-bit format.
In one embodiment, the image size of the two-dimensional image may include a width and a height in pixels, such as a width of 60 pixels and a height of 80 pixels, for example. In other embodiments, the image size of the two-dimensional image may include a width and a height in millimeters.
In block S303, the determination module 210 retrieves a pixel value of each pixel in the two-dimensional image from the pixel information according to the image format, and determines pixel coordinates of each pixel in the two-dimensional image according to the image size. In one embodiment of a two-dimensional image in an 8-bit format, the determination module 210 may retrieve an 8-bit pixel value, such as “10001010”, for each pixel in the two-dimensional image from the pixel information. In another embodiment of a two-dimensional image in a 16-bit format, the determination module 210 may retrieve a 16-bit pixel value, such as “1000101011000101”, for each pixel in the two-dimensional image from the pixel information.
The determination module 210 may determine the pixel coordinates of each pixel in the two-dimensional image according to a column number and a row number of the pixel in the two-dimensional image.
In block 5304, the calculation module 220 calculates a gray value for each pixel in the two-dimensional image according to the pixel value of the pixel. The pixel value of each pixel may consist of a red component value, a green component value, and a blue component value. One example of a formula to calculate the gray value may be as follows: gray value=R*0.3+G*0.59+B*0.11, where R, G, and B respectively represent a red component value, a green component value, and a blue component value of a pixel in the two-dimensional image. In another embodiment, the pixel value of each pixel in the two-dimensional image consists of a red component index, a green component index, and a blue component index. The calculation module 220 may determine a red component value, a green component value, and a blue component value corresponding to the red component index, the green component index, and the blue component index respectively. Accordingly, the gray value is calculated.
In block S305, the generation module 230 generates a three-dimensional point for each pixel in the two-dimensional image according to the pixel coordinates and the gray value of the pixel. In one embodiment of an X-Y-Z coordinate system, pixel coordinates of a pixel are defined as X-Y coordinates of a three-dimensional point, and the gray value of the pixel is defined as a Z coordinate of the three-dimensional point. For example, if pixel coordinates of a pixel are (5, 9) and a gray value of the pixel is 45, a three-dimensional point (5, 9, 45) is generated for the pixel.
In block S306, the generation module 230 generates a three-dimensional mesh by connecting all three-dimensional points corresponding to the pixels in the two-dimensional image. In one example of a 60×80 two-dimensional image, the generation module 230 generates 4800 three-dimensional points, and generates a three-dimensional mesh by connecting the 4800 three-dimensional points. In one embodiment, the three-dimensional mesh is a triangle mesh that comprises a number of contiguous triangles.
In block S307, the decoration module 240 decorates the three-dimensional mesh by adding surface characteristics to the three-dimensional mesh. As such, the three-dimensional image with a surface appearance in three dimensions is determined. The surface characteristics may include varied surface details such as color, texture, transparency, wrinkles, and pleats. In one embodiment, the decoration module 240 adds the surface characteristics to the three-dimensional mesh using a texture mapping method and/or a shading method. For example, the decoration module 240 may map a surface texture onto the three-dimensional mesh. The surface texture is a two-dimension image to be drawn on the three-dimensional mesh, each polygon in the three-dimensional mesh corresponding to a polygonal section of the surface texture.
In block S308, the display module 250 displays the decorated three-dimensional mesh on the display device 14.
Although certain inventive embodiments of the present disclosure have been specifically described, the present disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the present disclosure without departing from the scope and spirit of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
200910304845.9 | Jul 2009 | CN | national |