def encode(img, args): if args.format == "nifti": data = img.get_data() # data = affine.nifti2dicom(data) elif args.format == "dicom": data = img.pixel_array dim = data.shape data = data.ravel() if args.mode == "lsb": data = lsb.encode(data, args.msg, args.tiling) elif (args.mode == "haar"): print "Haar not implemented yet" return img data.shape = (dim) if args.format == "nifti": # data = affine.dicom2nifti(data) return nib.Nifti1Image(data, img.get_affine(), img.get_header()) elif args.format == "dicom": img.PixelArray = data.tostring() return img
def testEncodeAndDecodeTile(self): data = numpy.zeros(1000, dtype=numpy.uint32) encData = lsbstego.encode(data, self.msg, "tile") decMsgList = lsbstego.decode(encData) decMsg = lsbstego.listToText(decMsgList) self.assertEqual(decMsg, "[{0}]".format(self.msg))
def testEncodeAndDecodeOnRandomNotile(self): data = numpy.random.randint(0, high=256, size=1000).astype(numpy.uint32) encData = lsbstego.encode(data, self.msg, "notile") decMsgList = lsbstego.decode(encData) decMsg = lsbstego.listToText(decMsgList) self.assertEqual(decMsg, "[{0}]".format(self.msg))