Exemple #1
0
    def post(self, request, *args, **kwargs):
        pr, pb, enc_img = get_data(request)
        v = int(request.data['brightness'])
        out_img = ig.Secure_Image_Adjustment_Brightness_Control(enc_img, v, pb)

        # data = {
        # 	'enc_img' : enc_img,
        # 	'v' : v,
        # 	'pb' : pb
        # }
        # data2 = pickle.dumps(data,protocol=2)
        # url = "http://pailliercryptosystem.pythonanywhere.com/brightness_control"
        #
        # r = requests.post(url,data=data2)
        # out_img = pickle.loads(r.content)

        dec_img = dc.decrypt(pr, pb, out_img)
        out_json = encryptImage.toJson(out_img)
        omg = dc.convertToByte(dec_img)
        base64EncodedStr = base64.b64encode(omg)
        # data = {
        #     "cipher" : out_json,
        #     "b64" : base64EncodedStr
        # }
        data = {"b64": base64EncodedStr}
        return Response(data)
Exemple #2
0
    def post(self, request, *args, **kwargs):
        pr, pb, enc_img = get_data(request)
        omg = dc.decrypt(pr, pb, enc_img)
        omg = dc.convertToByte(omg)
        base64EncodedStr = base64.b64encode(omg)
        # print(base64EncodedStr)

        data = {"b64": base64EncodedStr}
        return Response(data)
Exemple #3
0
    def post(self, request, *args, **kwargs):
        pr, pb, enc_img = get_data(request)
        v = int(request.data['blur'])
        out_img = ig.Secure_Noise_Reduction_LPF(enc_img, v, v, pb)

        dec_img = dc.decrypt(pr, pb, out_img)
        omg = dc.convertToByte(dec_img)
        base64EncodedStr = base64.b64encode(omg)

        data = {"b64": base64EncodedStr}
        return Response(data)
Exemple #4
0
    def post(self, request, *args, **kwargs):
        pr, pb, enc_img = get_data(request)
        v = int(request.data['negation'])
        if v:
            out_img = ig.Secure_Image_Adjustment_Image_negation(
                enc_img, 255, pb)
        else:
            out_img = enc_img
        dec_img = dc.decrypt(pr, pb, out_img)
        omg = dc.convertToByte(dec_img)
        base64EncodedStr = base64.b64encode(omg)

        data = {"b64": base64EncodedStr}
        return Response(data)
Exemple #5
0
    def post(self, request, *args, **kwargs):
        pr, pb, enc_img = get_data(request)
        kerX = [[1, 0, -1], [2, 0, -2], [1, 0, -1]]
        kerY = [[1, 2, 1], [0, 0, 0], [-1, -2, -1]]

        out_img1 = ig.sobelOperator(enc_img, kerX, pb)
        out_img2 = ig.sobelOperator(enc_img, kerY, pb)

        dec_img1 = dc.decrypt(pr, pb, out_img1)
        dec_img2 = dc.decrypt(pr, pb, out_img2)
        dec_img = copy.deepcopy(dec_img1)
        n, m = len(dec_img), len(dec_img[0])
        for i in range(n):
            for j in range(n):
                dec_img[i][j] = max(
                    0,
                    min(255,
                        int(math.sqrt(dec_img1[i][j]**2 + dec_img2[i][j]**2))))

        omg = dc.convertToByte(dec_img)
        base64EncodedStr = base64.b64encode(omg)

        data = {"b64": base64EncodedStr}
        return Response(data)