Summary of the invention
To the problem that prior art exists, fundamental purpose of the present invention is to provide that a kind of data volume is little, storage speed fast, visit Machine Vision Detection result's storage file and method easily.
Be to realize above-mentioned purpose, the invention provides a kind of Machine Vision Detection result's storage file, be used to store the testing result after the Machine Vision Detection.This Machine Vision Detection result's storage file comprises an image data file and an image list file; This image data file comprises one with the view data after the compression of epigraph with to the testing result data of this view data; This each open image the testing result data followed by the back that is stored in the view data after the corresponding compression; This image list file comprises file header information and image set essential information; This document header is the foundation that all images data are compressed; And this document header only comprises quantization table and Huffman table, has omitted other file header information except quantization table and Huffman table in the common jpeg image, and only preserves file header information one time to all view data to be compressed.In addition; This image list file also comprises view data and the positional information of testing result data after all compressions of storing in the image data file; Specifically; The positional information of the view data after the compression is meant start address and the data length of view data in image data file after the compression, and the positional information of testing result data in image data file is meant start address and the data length of testing result data in image data file.In addition, this image list file also comprises the width and the elevation information of all images data of storing in the image data file.
The present invention also provides a kind of Machine Vision Detection result's storage means, is used to store the testing result after the Machine Vision Detection, and this storage means comprises following steps:
(1) creates an image list file and an image data file;
The file header information of the foundation that (2) will compress as view data to be stored is kept in the image list file; And only preserve file header information one time to all view data to be compressed; This document header only comprises quantization table and Huffman table; Omitted other file header information except quantization table and Huffman table in the common jpeg image, and this quantization table is to set up through the quality factor that input compressed images data need reach;
(3) view data to be stored is compressed according to the file header information of preserving in the image list file;
(4) image data storage after will compressing is in image data file;
(5) positional information of view data in image data file after the compression of the current storage of record in the image list file; The positional information of view data after the compression of this image list file logging in image data file is meant start address and the data length of view data in image data file after the compression; In addition, the width and the elevation information of the image list file all images data of also storing in the recording image data file;
(6) with the back of the view data of the testing result data after the Machine Vision Detection after followed by the compression that is kept at current storage, view data after the compression and testing result data constitute the storage to the current detection image;
(7) positional information of testing result data in image data file of the current storage of record in the image list file, the positional information of these testing result data in image data file is meant start address and the data length of testing result data in image data file;
(8) whether the remaining space of judge disk can store down piece image;
(9) if any piece image under the remaining space storage, then continue next view data to be stored is compressed; Otherwise, write end-of-file mark, finish the preservation of image.
View data to be stored compressed according to the file header information of preserving in the image list file comprises following steps:
(1) view data is divided into a plurality of 8 * 8 matrix, the multiple by 8 of the multiple of less than 8 is used 0 polishing;
(2) each matrix of 8 * 8 is done cosine transform, obtain a matrix of frequency coefficients;
(3) coefficient of frequency after the cosine transform is carried out data-measuring;
(4) to the view data after promptly obtaining compressing of encoding of the view data after quantizing.
In addition, when view data to be stored is gray level image, when then view data to be stored being compressed, only the Y value of gray level image is compressed, can be improved the compression speed of view data greatly.
Compared with prior art, beneficial effect of the present invention is: (1) data volume is little: all images is kept at after overcompression in the image data file, so data volume is very little; (2) storage speed is fast, safe: when handling gray level image, the data compression time only need be compressed the time of the jpeg format data about 1/3 of same data volume, has prevented in the high speed image storage to fall with the JPEG compress mode situation of figure.(3) common jpeg image all need be preserved file header information one time to each image when storage, the present invention is when storing image data; Omitted the file header information of some JPEG; As omitted image recognition information, compressibility etc., and identical file header information such as quantization table, Huffman table, only preserve once to all images; Suitable minimizing the size of file; And preserve again through after view data is compressed, then reduced the data volume of file greatly, be user-friendly to; (4) visit fast: record view data and the listing file of testing result data essential information after the compression through creating an image data file and one; All images data and detection data all are stored in together; Can make things convenient for copying data and detect data transmission; Can realize that also the testing result data follow detection picture is walked, be convenient to targetedly viewing files fast.And, also improved the speed and the convenience of visit greatly owing to only need just can find needed view data and testing result data through an image list file.
Embodiment
Below in conjunction with accompanying drawing, specify embodiment of the present invention.
As shown in Figure 1, be the structural drawing of JPEG in the prior art (Joint Photographic Experts Group) image.JPEG (Joint Photographic Experts Group) is an international digital image compression standard of being set up for still image by International Standards Organization (ISO:International Standardization Organization) and Consultative Committee on International Telephone and Telegraph (CCITT) (CCITT:Consultation Commitee of the International Telephone and Telegraph).View data 14 two parts after the jpeg image 10 of process JPEG compression standard compression comprises file header 12 and compresses, wherein file header 12 comprises image recognition information 121, quantization table 122, Huffman table 123, compressibility 124 and image essential information 125 or the like.Wherein quantization table 122 is to set up according to the quality factor of input, and the quality factor of input is big more, and then the compressibility after the compression of images 124 is high more.And image essential information 125 comprises width 1251, the height 1252 etc. of view data.
Specify the effect of these fields that comprise in the file header 12 below through the compression step of JPEG.The JPEG compression specifically comprises the steps:
(1) color conversion:, and do not support RGB (Red because JPEG only supports the data structure of YUV (Y representes gray-scale value, and U, V represent colourity) color mode; Green; Blue) data structure of image is so before coloured image is compressed, must be the image of YUV pattern with the image transitions of RGB pattern; If gray-scale map does not then need this step.Also need carry out data sampling after converting.The general sampling ratio that adopts is 2: 1: 1 or 4: 2: 2.After having carried out sampling work, per two line data only keep delegation.Therefore, sampling back image data amount is with original half the of boil down to.
(2) dct transform.DCT (Discrete Consine Transform, discrete cosine transform) be with picture signal in the enterprising line translation of frequency field, isolate high and low frequency information processing process.And then the HFS of image compressed, to reach the purpose of compressing image data.At first be a plurality of 8 * 8 matrix with image division, then each matrix made dct transform, obtain a matrix of frequency coefficients after the conversion, coefficient of frequency wherein all is a floating number.
(3) quantize.Coefficient of frequency to after the conversion quantizes, and converts it to integer.According to the input quality factor set up quantization table 122, quality factor choose with compress after picture quality and compressibility 124 confidential relation is arranged.The value of quality factor is selected too much, can increase substantially compressibility 124, but picture quality is just poor; Otherwise quality factor is more little, and picture quality is good more, but compressibility 124 is low more.
(4) coding.The dct transform of front and quantification are to prepare for coding stage.Coding adopts two kinds of mechanism: one is the run length encoding of 0 value; The 2nd, entropy coding (Entropy Coding) is promptly accomplished the compression of image after coding is accomplished.
Machine Vision Detection result's of the present invention storage file is used to store the testing result after the Machine Vision Detection.This Machine Vision Detection result's storage file comprises an image data file 40 and an image list file 20.
As shown in Figure 4, be the Machine Vision Detection of the present invention structural drawing of the image data file 40 of storage file as a result.This image data file 40 comprises the image more than or; As shown in Figure 4; Comprise [the 1st image], [the 2nd image] ... [n image], the quantity of image is by the size of every image and the common decision of size of disk, and all images all are stored in the image data file 40.Every image all comprises the view data 14 and testing result data 41 after the compression, and these image stored data are through overcompression, and compress mode can be identical with the compress mode of common JPEG.Characteristics are, each testing result data 41 of opening image is followed by the back that is stored in the view data 14 after the corresponding compression, with convenient inquiry.It is pointed out that in this image data file 40 that view data 14 after the compression of storage does not comprise like file header information such as the quantization table 122 that comprised in the common jpeg image, Huffman tables 123.
As shown in Figure 2, be Machine Vision Detection of the present invention image list file 20 structural drawing of storage file as a result.This image list file 20 include file beginning flags 21, quantization table 122, Huffman table 123, image set essential information 22 and end-of-file mark 23.To all images in the image data file 40; Only preserve the file header information of once forming by quantization table 122, Huffman table 123; Quantization table 122 is to set up through the quality factor that the input compressed images need reach; The quality factor of this input is determining the compressibility and the compression quality of image, and these information all are view data to be compressed foundation is provided.It should be noted that the file header information that the image list file 20 is here preserved only comprises quantization table 122 and Huffman table 123, and omitted other file header information except quantization table 122 and Huffman table 123 in the common jpeg image.And for each image in the image data file 40; Set up image essential information 125 respectively; As shown in Figure 4; Comprise [the image essential information 125 of the 1st image], [the image essential information 125 of the 2nd image] ..., up to [the image essential information 125 of n image], form image set essential information 22 jointly.
As shown in Figure 3, be the structural drawing of the image essential information 125 of image list file 20.The image essential information 125 of every image all comprises the width 1251 of view data, the height 1252 of view data, also comprises the positional information that view data 14 and testing result data 41 after the compression are stored in image data file 40.The start address 1253 of view data 14 after the positional information of view data 14 in image data file 40 after this compression comprises compression in image data file 40 and the data length 1254 of the view data after the compression; Equally, the positional information of testing result data 41 in image data file 40 comprises the start address 1255 of testing result data 41 in image data file 40 and the data length 1256 of testing result data 41.The positional information of in image data file 40, storing according to view data after the compression of image list file 20 preservations 14 and testing result data 41 can find the position of need query image in image data file 40.
As shown in Figure 5, the storage means process flow diagram for Machine Vision Detection result of the present invention specifically comprises the steps:
S51, an image list file 20 of establishment and an image data file 40;
The file header information of S52, the foundation that will compress as view data to be stored is kept in the image list file 20, and only preserves file header information one time to all view data to be compressed.File header information comprises quantization table 122 and Huffman table 123; This quantization table 122 is to set up through the quality factor that the input compressed images need reach; Setting up quantization table 122 back regeneration Huffman tables 123, again quantization table 122 and Huffman table 123 are kept in the image list file 20 afterwards.It should be noted that the file header information that the image list file 20 is here preserved only comprises quantization table 122 and Huffman table 123, and omitted other file header information except quantization table 122 and Huffman table 123 in the common jpeg image;
S53, view data to be stored is compressed according to the file header information of preserving in the image list file 20.Specifically comprise the steps: at first, view data is divided into a plurality of 8 * 8 matrix, the multiple by 8 of the multiple of less than 8 is used 0 polishing; Secondly, each matrix is done cosine transform, obtain a matrix of frequency coefficients; Once more, the coefficient of frequency after the cosine transform is carried out data-measuring; At last, the view data after quantizing being encoded, if view data is colored, need be the YUV image with the RGB image transitions at first also then.It should be noted that if to gray level image, then have some difference with common JPG compress mode.When using common JPG compress mode that gray level image is compressed, at first gray level image is become YUV (Y representes gray-scale value, and U, V represent colourity) form, wherein Y is exactly a gray value data after changing.And to gray level image, U and V value all are 0.Common JPG compress mode is not only compressed the Y value, also will the data value of U and V be compressed respectively.But in high speed machines vision system of the present invention, when gray level image is compressed,,, not only lose time, but also take up room the data after the store compressed if it is carried out processed compressed because U in the gray level image and V value all are 0.Therefore in gray-scale map compression method of the present invention, only Y (gray-scale value) is carried out processed compressed, directly give up U and V value.Be merely original 1/3rd through the compression speed that experiment showed, this compression method, and the data volume after the compression has reduced also.
S54, the view data 14 after will compressing are stored in the image data file 40;
S55, in image list file 20, note the essential information of the view data 14 after the compression of current image stored, comprise the width 1251 of view data, height 1252, the start address 1253 of the view data 14 after the compression in image data file 40 and the data length 1254 of the view data after the compression of view data;
The storage that the back of S56, the testing result data 41 after NI Vision Builder for Automated Inspection the handled view data 14 after followed by the compression that is kept at current storage, the view data 14 after the compression and testing result data 41 constitute the current detection image;
S57, in image list file 20, note the reference position 1255 of testing result data 41 in image data file 40 and the data length 1256 of testing result data 41 of image stored;
Whether the remaining space of S58, judge disk can store down piece image, if can also store down piece image, and then to S53, otherwise, to S59;
S59, write end-of-file mark, finish the preservation of image.
Behind the storage means storage file that uses Machine Vision Detection result as shown in Figure 5, of Fig. 6, for the present invention visits the Machine Vision Detection process flow diagram of storage file as a result, specifically comprise the steps:
S61, open image list file 20 and image data file 40;
S62, find the position of view data 14 in image data file 40 after the compression that needs query image according to the start address 1253 of the view data 14 after the compression of the image of preserving in the image list file 20 and data length 1254;
S63, from image data file 40, read the view data 14 after the compression of the image that needs inquiry;
S64, the view data after the compression in the image 14 is decompressed, recover the view data before the compression;
The start address 1255 and the data length 1256 of the testing result data 41 of S65, the image preserved according to image list file 20 find the position of testing result data 41 in image data file 40 that needs query image;
S66, the testing result data 41 of from image data file 40, reading image finally obtain needing the view data and the testing result data 41 of query image.
More than introduced Machine Vision Detection result's storage file and method, can make that the files stored data volume diminishes, storage speed is accelerated and convenient visit.But the present invention is not limited to above embodiment, does not anyly break away from technical scheme of the present invention, promptly only it is carried out improvement or the change that those of ordinary skills knew, all belongs within protection scope of the present invention.