Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to do arnold and inverse arnold transform?

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);

How to do arnold and inverse arnold transform?

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;
i1=(2*j-i)%128;
                        int j1=(-i+j)%128;
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);

How to do arnold and inverse arnold transform?Anold Transform

Hello every one, I am trying to do arnold and inverse arnold transform. I have written code according to formulas for image scrambling and inverse scrambling using Arnold transform. Inputs: 1. number iterations for scrambling is any arbitary number between 0 and period of Arnold transform for the given in literature. I am able to do size=enciter. 2. number of iterations for inverse scrambling=>deciter = period-enciter. for 128x128 image period of arnold transform but inverse transform is not coming. I am getting negative coefficients. How to solve problem? Thank you.. the code is as follows::

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;

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);
               imshow("Input Image",im);
               Mat randseq_cap=Mat::zeros(im.size(),CV_8U);
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<132;iter++)
            { 
 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 i=0;i<128;i++)
 iter=0;iter<deciter;iter++)
               {
                    for(int j=0;j<128;j++)
                    {      
            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 i1=(i+j)%128;
                        int j1=(2*i+j)%128;
                        randseq_cap.at<uchar>(i1,j1)=im.at<uchar>(i,j); 
        main()
            {
                image my;
                my.getim();
                return 0;
            }
                }
                 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*j-i)%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);

            ![Input Image](/upfiles/1423303924683476.png) 
            ![Scrambled Image](/upfiles/1423303954768847.png)
            ![Inverse Scrambled Image](/upfiles/14233040328729346.png)

Anold Transform

Hello every one, I have written code for image scrambling and inverse scrambling using Arnold transform. Inputs: 1. number 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;

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;
            }

            ![Input Image](/upfiles/1423303924683476.png) 
            ![Scrambled Image](/upfiles/1423303954768847.png)
            ![Inverse Scrambled Image](/upfiles/14233040328729346.png)
![image description](/upfiles/1423304278947551.png)
click to hide/show revision 5
No.5 Revision

updated 2015-02-07 04:20:19 -0600

berak gravatar image

Anold Transform

Hello every one, I have written code for image scrambling and inverse scrambling using Arnold transform. Inputs: 1. number 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;
            }

          ![image description](/upfiles/1423304278947551.png)

image description

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;
            }

image description