hello , i have written code for image scrambling using logistic map. the code is given below. Similar algortihm works well in MATLAB but in OPENCV i am getting original image as it is. not a scrambled one. How to resolve the problem?
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\core\core.hpp>
#include <opencv2\core\mat.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include<iostream>
#include<math.h>
#include<conio.h>
using namespace std;
using namespace cv;
class image
{
public:
Mat im,im1,im2,cs,im_enc;
int getim();
};
int image::getim()
{
im=imread("logo1.jpg",0);
if (im.empty())
{
cout << "Error : Image cannot be loaded..!!" << endl;
return -1;
}
im1=Mat::zeros(im.rows,im.cols,CV_8U);
threshold(im,im1,128,255,1);
cs=Mat::zeros(im.rows,im.cols,CV_8U);
im_enc=Mat::zeros(im.rows,im.cols,CV_8U);
float x_new,x_old=0.7;
for(int rc=1;rc<im1.rows+1;rc++)
{
for(int cc=1;cc<im1.cols+1;cc++)
{
for(int iter=1;iter<rc*cc+1;iter++)
{
x_new=x_old*4*(1-x_old); //Logistic map
x_old=x_new;
}
if(x_old>=0.5)
cs.at<uchar>(rc,cc)=255;
else
cs.at<uchar>(rc,cc)=0;
}
}
bitwise_xor(im1,cs,im_enc,noArray());
waitKey(4000);
cout<<""<<im_enc;
namedWindow("Scrambled Image",CV_WINDOW_AUTOSIZE);
imshow("Scrambled Image",im_enc);
waitKey(0);
return 0;
}
int main()
{
image my;
my.getim();
return 0;
}