Histogram-based Image Search

Source: Internet
Author: User

Overview of the general process of Image Search: extracting image feature values → processing feature values → matching feature values there are many feature values based on color features, texture features, shape features, etc, the following is an image search based on the image color histogram features. (Reference article: http://blog.csdn.net/jia20003/article/details/7771651#comments) Principle bhattacharyyaco efficient algorithm, P, P represent the source and candidate image histogram data, respectively, after the product of each data point with the same I value is square, the result is the image similarity value (the factor value of the babacache coefficient), ranging from 0 to 1. Why is it between 1? This is a mathematical problem and I will not investigate it. Step 1. Find the source image and the histogram feature of the image to be searched 2. According to the histogram feature, the similarity between the source image and the image to be searched is obtained using the coefficient algorithm. Each pixel of the color image is composed of red, green, and blue. How can we better represent the histogram of the color image? There are two methods: one is represented by a three-dimensional histogram, which is simple and clear, for example, hist [] [], hist [0] [] represents the red histogram, hist [1] [] indicates the histogram of green. hist [2] [] indicates the histogram of blue. For example, if a pixel is (, 89 ), then hist [0] [156] ++; hist [0] [72] ++, hist [0] [89] ++; another method is to reduce the gray level, represented by a one-dimensional histogram. For example, to reduce the gray level of 256 to 16, a 12-bit int is used to represent the gray level, and the first four digits are red, four in the middle represent green, and the last four digits represent blue. one pixel is (156/16, 89), r = 72/16 = 9; g = 89/16 = 4, B = 5; index = r <(2*4) | g <4 | B; hist [index] ++; source code 3D histogram represents [java]/*** to find a 3D grayscale histogram * @ param srcPath * @ return */public static double [] [] getHistgram (String srcPath) {BufferedImage img = ImageDigital. readImg (srcPath); return getHistogram (img);}/*** hist [0] [] red histogram, hist [1] [] green histogram, hist [2] [] blue histogram * @ param img image to obtain the histogram * @ return returns r, g, b's three-dimensional histogram */public static double [] [] getHistogram (BufferedImage img) {int w = img. getWidth (); int h = img. getHeight (); double [] [] hist = new double [3] [256]; int r, g, B; int pix [] = new int [w * h]; pix = img. getRGB (0, 0, w, h, pix, 0, w); for (int I = 0; I <w * h; I ++) {r = pix [I]> 16 & 0xff; g = pix [I]> 8 & 0xff; B = pix [I] & 0xff; /* hr [r] ++; hg [g] ++; hb [B] ++; */hist [0] [r] ++; hist [1] [g] ++; hist [2] [B] ++;} for (int j = 0; j <256; j ++) {for (int I = 0; I <3; I ++) {hist [I] [j] = hist [I] [j]/(w * h ); // System. out. println (hist [I] [j] + "") ;}} return hist;} public double indentification (String srcPath, String destPath) {BufferedImage srcImg = ImageDigital. readImg (srcPath); BufferedImage destImg = ImageDigital. readImg (destPath); return indentification (srcImg, destImg);} public double indentification (BufferedImage srcImg, BufferedImage destImg) {double [] [] histR = getHistogram (srcImg ); double [] [] histD = getHistogram (destImg); return indentification (histR, histD);} public static double indentification (double [] [] histR, double [] [] histD) {double p = (double) 0.0; for (int I = 0; I

Related Article

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.