Anold Transform
Hello every one, I have written code for image scrambling and inverse scrambling using Arnold transform. Inputs: 1. number of iterations for scrambling is any arbitary number between 0 and period of Arnold transform for the given size=enciter. 2. number of iterations for inverse scrambling=>deciter = period-enciter. for 128x128 image period of arnold transform is 96. Refer relevant pepper of arnold tranform for periods of different sizes .
#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);
if (im.empty())
{
cout << "Error : Image cannot be loaded..!!" << endl;
return -1;
}
resize(im,im,Size(128,128),0.0,0.0,1);
imshow("Input Image",im);
Mat temp=Mat::zeros(im.size(),im.type());
double m=im.rows,x,x1,y,y1;
int enciter=50;
int deciter=96-enciter;
for(int iter=0;iter<enciter;iter++)
{
for(double i=0;i<m;i++)
{
for(double j=0;j<m;j++)
{
x=fmod((i+j),m);
y=fmod((i+2*j),m);
temp.at<uchar>(x,y)=im.at<uchar>(i,j);
}
}
temp.copyTo(im);
temp=Mat::zeros(im.size(),im.type());
}
imshow("Scrambled Image",im);
for(int iter=0;iter<deciter;iter++)
{
for(double i=0;i<m;i++)
{
for(double j=0;j<m;j++)
{
x=fmod((i+j),m);
y=fmod((i+2*j),m);
temp.at<uchar>(x,y)=im.at<uchar>(i,j);
}
}
temp.copyTo(im);
temp=Mat::zeros(im.size(),im.type());
}
imshow("Inverse Scrambled Image",im);
waitKey(0);
return 0;
}
int main()
{
image my;
my.getim();
return 0;
}
since you do a modulo anyway, might as well add (a multiple) of 128
hi @Mahavir, with your latest edit, the question somehow got lost.
what's the problem with in now ?