Hello every one, I am trying to do arnold and inverse arnold transform. I have written code according to formulas given in literature. I am able to do arnold transform but inverse transform is not coming. I am getting negative coefficients. How to solve problem? Thank you.. the code is as follows::
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\core\core.hpp>
#include <opencv2\core\mat.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include<opencv2\features2d\features2d.hpp>
#include<iostream>
#include<math.h>
#include<conio.h>
using namespace std;
using namespace cv;
class image
{
public:
Mat im,im1,im2,im3,cs,im_enc,frame;
int getim();
};
int image::getim()
{
im=imread("Caption.png",0);
threshold(im,im,128,255,THRESH_BINARY);
if (im.empty())
{
cout << "Error : Image cannot be loaded..!!" << endl;
return -1;
}
imshow("My",im);
resize(im,im,Size(128,128),0.0,0.0,1);
Mat randseq_cap=Mat::zeros(im.size(),CV_8U);
for(int iter=0;iter<132;iter++)
{
for(int i=0;i<128;i++)
{
for(int j=0;j<128;j++)
{
int i1=(i+j)%128;
int j1=(2*i+j)%128;
randseq_cap.at<uchar>(i1,j1)=im.at<uchar>(i,j);
}
}
im=randseq_cap;
}
imshow("scrambled Image",randseq_cap);
for(int iter=0;iter<132;iter++)
{
for(int i=0;i<128;i++)
{
for(int j=0;j<128;j++)
{
int i1=(2*i-j)%128;
int j1=(-i+j)%128;
im.at<uchar>(i1,j1)= randseq_cap.at<uchar>(i,j);
}
}
randseq_cap=im;
}
imshow("Re-scrambled Image",im);
waitKey(0);