C + + implementation of Grid watermark Debug Note (v)--extraction error

Source: Internet
Author: User

In the process of extracting watermark, some problems are encountered.

First of all, according to the ideas in the paper to comb the entire extraction process

    1. Read into two models, a primitive model Ori_mesh, a watermark model Wm_mesh.
    2. Align two models (that is, in the same coordinate system)
    3. The spectral coefficients of two models were calculated, the spectral coefficients of Ori_mesh were RS, Rt, Ru, Wm_mesh, and the spectral coefficients of WRs, WRt and WRU were recorded.
    4. Calculate QJ According to the following formula

    5. According to the following formula to calculate the embedded watermark symbol, here is equivalent to get embedded watermark B ', just remember that AJ

    6. Finally, the original watermark sequence B is obtained according to the following formula

?

Based on the above steps, I started with the idea of reading two models under the grid platform, and then doing the calculations in the above steps would be a bit of a hassle, such as getting a grid, although you can use a linked list to store open files, but when initializing the grid, because the parameters are separate, If it's all rewritten as an array or a linked list, it can be quite cumbersome to change. So I decided to embed the watermark when the R matrix is written to the file, so that when the watermark is not read into the original grid, just calculate the read into the watermark grid in the WR matrix, and then read out the R matrix from the file, the difference between the two, and then the original steps to Judge .

?

The write and read are as follows:

//write the spectral coefficients of the original mesh to the file Rs????????

Ofstream Rsfile;

???????? rsfile. Open ("D:\\rs.txt",ios_base:: out);

???????? if ( rsfile)

???????? {

???????????? for ( inti = 0; I < m_vertexnum; I+ +)

???????????? {

???????????? rsfile<<Rs[i]<<"";

????????????}

????????}

???????? rsfile. Close ();

?

???? Read the spectral coefficients of the original mesh from the file

???????? Double *pRs = newdouble[m_vertexnum];

???????? Double *pRt = newdouble[m_vertexnum];

???????? Double *pRu = newdouble[m_vertexnum];

?

???????? //rs

???????? Ifstream Rsfile;

???????? rsfile. Open ("D:\\rs.txt",ios_base:: in);

???????? if (rsfile)

???????? {

???????????? //Read into memory

???????????? rsfile. SEEKG (0, rsfile. end);

???????????? int length = rsfile. Tellg ();

???????????? rsfile. SEEKG (0, rsfile. Beg);

?

???????????? Char *buffer = newchar[length];

???????????? rsfile. Read (buffer, length);

???????????? rsfile. Close ();

?

???????????? //Parse into array

???????????? std::istringstreamISS(buffer);

???????????? int I = 0;

???????????? while (ISS >> pRs[i+ +]);

???????????? Delete [] buffer;

???????????? //print or use it.

????????}

???????? rsfile. Close ();

In the process of extraction, the main problem is on the sign function, because not find the sign function belongs to the header file, so I myself implemented a sign function, the code is as follows:

Double eigendeformation::sign ( doublex)

???? {

???????? cout <<"x ="<< x <<Endl;

???????? if ( x > 0)

???????????? return 1;

???????? Else if (fabs(x) < 0.000000000001)

???????????? return 0;

???????? Else

???????????? return -1;

????}

Because of the accuracy of the relationship, the sign function determines that the symbol is always incorrect, debug view the value of the input sign function and its output only as follows:

where x is the input value, p is the value that is obtained after the judgment.

Then common sense will be the input to enlarge 1kw times also failed.

use a different function instead ? double _copysign (double x, double y);

This function is a function of math.h in C, function: Return the first parameter x with the sign of the second parameter Y (positive or negative), and call the form in the code as follows:

WB [i] = _copysign(1, Q[i]);

The results are as follows:

The return symbol succeeds, comparing the embedded watermark sequence

How do the two differ so much ...

The results of P are the same each time they are run.

?

?

Error 1: When the RT is read into the file, it is written in Rs.

Error 2: Vertex Assignment method Error

Correct:

R of the original grid R watermark Grid

?

C + + implementation of Grid watermark Debug Note (v)--extraction error

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.