public static byte[] readData(BufferedImage image, byte[] otp) {
        byte[] lengthBytes = new byte[4];
        int bit = 0;
        int dataLength = 4;
        byte[] bytes = null;

        for (int y = 0; y < image.getHeight() && (bit / 8) < dataLength; y++) {
            for (int x = 0; (x + 3) < image.getWidth() && (bit / 8) < dataLength; x += 4) {

                int sum = 0;
                for (int xx = 0; xx < 4; xx++) {
                    int sample[] = new int[4];
                    sample = image.getRaster().getPixel(x + xx, y, sample);
                    for (int ii = 0; ii < 3; ii++) {
                        sum += sample[ii];
                    }
                }

                int bitValue = sum % 2;
                if (otp != null) {
                    bitValue = bitValue ^ otp[bit];
                }
                bitValue = bitValue << (bit % 8);

                if ((bit / 8) < 4) {
                    lengthBytes[bit / 8] += bitValue;
                    if (bit == 31) {
                        dataLength = readLengthBytes(lengthBytes);
                        bytes = new byte[dataLength];
                        dataLength += 4;
                    }
                } else {
                    bytes[(bit / 8) - 4] += bitValue;
                }
                bit++;
            }
        }
        return bytes;
    }