0
votes

i am working on image encryption and decryption algorithm. i want to make image pixel distorted. i want to get every pixel value and then sort these pixel value the way i want so that pixel of image is distorted and image changed. is am i going in the rite direction? any hint? or example algorithm which will help me out.

Idea:

i have an image of 10*10 pixel. it means image comprises of 100 pixels. if i pick 1st pixel row of image which is 10 pixels, i convert these pixels in binary and then decimal. now i get 10 decimal values of pixels. i sort these values the way i want. now converting the decimal values to binary and the into pixel. image pixels of the first row is now distorted.

2
What have you done so far?SMUsamaShah
nothing just proposed an idea, wanted to know is i am going in rite way? i mean is it possible to implement?Roshaan Nayyar

2 Answers

0
votes

I would not think about that as "image" anymore.

Basically, you have an array of "0-255" numbers and you want to hide their values and order. The only limitation is that you want to keep the range of values (0-255) and count - therefore you cannot use common alghorithms as they changes that too...

I would recommend do some shuffling and then changing values by some pattern. It is easy to implement and the picture will not be recognizable.

Also remember that the password should be the parameter which defines the way the picture is modified.

0
votes

There are many ways to do that. A simple approach:

  • Get all pixels Red, Green, Blue (0-255) values and put in a single byte array.
  • Encrypt the byte array.
  • Set the encrypted values back to the pixels.

You might work directly with pixel's byte array. But, just to illustrate, the example below access pixels individually using an image processing framework. The code does not change the image in any sense. It just illustrate how access and set back the pixels values.

    // Loading an image
    MarvinImage image = MarvinImageIO.loadImage("image.png");

    for (int x = 0; x < image.getWidth(); x++) {
        for (int y = 0; y < image.getHeight(); y++) {

            // 2. Accessing pixel at x,y
            int red = image.getIntComponent0(x, y); 
            int green = image.getIntComponent1(x, y); 
            int blue = image.getIntComponent2(x, y);

            // 3. Setting values back to pixel at x,y
            image.setIntColor(x,y,red,green,blue);                 
        } 
    }

    // 4. Saving image
    MarvinImageIO.saveImage(image, "image_out.png");

WARNING: Do not use image formats with compression like JPEG. They will change the pixel values slightly, therefore you cannot retrive the values back. Try to use formats like PNG.