Fractal Dimension Box Dimension texture features

Source: Internet
Author: User

Fractal Box Dimension texture features

In texture feature extraction, texture fragment dimension feature (FD) is an important description of texture. The more complex and delicate the image texture, the greater the fragment dimension. There are many methods to extract fractal dimension features, with different theoretical and computational complexity.

In this paper, the calculation method of the fractal dimension uses the DBC (differential box-counting), that is, the differential Box Counting Method. This method was proposed by Sarkar and Chaudhuri around 1994 (an efficient differential box-counting approach to compute
Fractal Dimension of image), an important improvement in the calculation method of fractal dimension, greatly improving the calculation and accuracy of FD. During the compilation of the algorithm in this paper, we also refer to two Chinese summaries: [calculation of the fractal dimension of two-dimensional grayscale images. Zhang Zhi], [Comparison of image fractal dimension calculation methods. Zhao Haiying].

In order to save space, we will first list the basic formulas used and the arguments in the original works of Sarkar. For other basic knowledge points, you can refer to the above two Chinese summaries.

 


D is the required texture fragment dimension feature. Because D is the slope of the straight line corresponding to NR and 1/R, it is necessary to change R multiple times, that is, the grid size, obtain multiple sample points, and finally obtain the final D through linear fitting.


The texture fragment dimension calculated using the DBC method is between 2 and 2 ~ 3. This is proven theoretically. In the original works of Sarkar, it is mentioned only and has not been proved to be:


In [calculation of the fractal dimension of two-dimensional gray images. Zhang Zhi], the author gives a proof of FD <3. The proof of FD> 2 is similar. In the [calculation of the fractal dimension of two-dimensional gray images. Zhang Zhi], the author mentions the problem of the BC method of Sarkar, that is, the excessive empty box exists in the DBC method. Therefore, this article pays attention to this problem during program design, eliminates the impact of empty boxes, and achieves better FD computing results.

The code of the fragment box dimension in this design is provided. The Code has been verified that the FD value conforms to the texture complexity. Theoretically, the FD value itself should also have the "Three unchanged" feature: translation, rotation, and scaling. It has been verified that the algorithm has the immutability of scaling on some images, and the non-deformation of translation and rotation is not verified yet.

We hope you can correct the redundancy, discomfort, and bugs in the code.

(The basic principle of least square method fitting: http://blog.csdn.net/ice_fire3/article/details/6709929)

// ************************ // Calculate the dimension of the fractal box. // yangxin_szu 2013_03_28 **** // valarray conflicts with MFC // # UNDEF is used to avoid problems # ifdef min # UNDEF min # endif # ifdef Max # UNDEF Max # endif # include <valarray> using namespace STD; void my_texture: calculate_fractal_dim (unsigned char * img_data, int img_size) {//************************************* * ********** // the width and height of the image shocould be the same // gray level: 256 // points for Least Square Method: 20 //************************************* * *********** // int I = 0, j = 0; // fragment Box Dimension parameter int M = img_size; // image size int G = 256; // image gray level int l_point = 20; // The sample points of the least squares method valarray <unsigned char> img_val (img_size * img_size); valarray <int> l_val (l_point); valarray <int> h_val (l_point ); valarray <double> r_val (l_point); valarray <double> nr_val (double) 0, l_point); valarray <int> grid_num (l_point ); // Number of grids valarray <double> fractal_d (0.0, l_point); // copy data int K = 0; for (I = 0; I  grid_img (unsigned char) 0, l_val [k] * l_val [k]); For (m = 0; m <grid_num [k]; m ++) {for (n = 0; n <grid_num [k]; n ++) {// coordinate range of a single grid grid_lt_x = N * l_val [k]; grid_lt_y = m * l_val [k]; grid_rd_x = grid_lt_x + l_val [k]-1; grid_rd_y = grid_lt_y + l_val [k]-1; // copy data T = 0; for (I = grid_lt_y; I <grid_rd_y; I ++) {for (j = grid_lt_x; j <grid_rd_x; j ++) {grid_img [T] = img_data [I * m + J]; t ++ ;}} grid_ I _min = grid_img.min (); grid_ I _max = grid_img.max (); // The grid height of the smallest and largest gray scale, dbc_k = grid_ I _min/h_val [k]; dbc_l = grid_ I _max/h_val [K // ******* calculate the number of empty boxes ******* // For (S = dbc_k; S <= dbc_l; s ++) {// gray_k = S * h_val [k]; gray_l = gray_k + h_val [k]-1; // clears box_non_zero = 0; // points that fall in the specified box for (P = 0; P <T-1; P ++) {If (grid_img [p]> = gray_k) & (grid_img [p] <= gray_l) box_non_zero ++;} // empty box if (box_non_zero = 0) box_zero_count ++ ;} // Nr accumulate and remove empty box Nr = dbc_l-dbc_k + 1-box_zero_count; nr_val [k] = nr_val [k] + nR; // clear box_zero_count = 0 ;}} nr_val [k] = log10 (double (nr_val [k]); grid_img.free () ;}// calculate the theoretical slope of each sample point and save fractal_d = nr_val/r_val; ofstream OUTFILE ("F: \ fractal_d.txt"); // open the file and prepare to write it to for (j = 0; j <l_point; j ++) {OUTFILE <fractal_d [J] <<'' <Endl; // DISTANCE} OUTFILE <Endl; OUTFILE. close (); // close the file, write //************************************ * *** // the least square method is used to fit a straight line of Double A = 0.0; double B = 0.0; double C = 0.0; double D = 0.0; A = (r_val * r_val ). sum (); B = r_val.sum (); C = (r_val * nr_val ). sum (); D = nr_val.sum (); double fractal_k, fractal_ B, TMP = 0; If (TMP = (A * L_point-B * B )) {fractal_k = (C * L_point-B * D)/tmp; fractal_ B = (A * D-C * B)/tmp;} else {fractal_k = 1; fractal_ B = 0 ;} // fractal_k; m_fractal_shift = fractal_ B; // release all valarray objects img_val.free (); l_val.free (); h_val.free (); r_val.free (); nr_val.free (); grid_num.free (); fractal_d.free ();}

Algorithm effect:

Fd= 2.73 FD = 2.85

FD = 2.14 FD = 2.16 FD = 2.886

The middle-black image may be caused by changes in edge pixels and Image Quality During plotting. The image is not pure black and FD is derived from point fitting. Therefore, the FD is not equal to 2 at this time. the above five images show that FD is well aligned with the fine density and complexity of texture distribution.



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.