'''Tutaj sender bedzie przekazywal obrazy. Nastepnie beda wykonywane na nich algorytmy a nastepnie wynik zostanie przekazany do receivera'''
import logging
import numpy as np
from PIL import Image
class Channel:
'''Inicjaliuje debug'''
def __init__(self):
logging.basicConfig(level=logging.DEBUG)
logging.debug("Channel created")
self.numpyImg = None
self.noisyImage = None
''' Przekazuje obraz receivera'''
def takeImage(self):
logging.debug("Przekazanie obrazka przez channel")
return self.noisyImage
''' Pobiera obraz z sendera'''
def receiveImage(self,npyImage):
logging.debug("Odebranie obrazka przez channel")
self.numpyImg=npyImage
'''Dodaje załucenia do obrazu który znajduje się w kanale'''
def addNoise(self):
logging.debug("Dudawanie zakłuceń")
row,col,ch= self.numpyImg.shape
mean = 0.0
var = 0.9
sigma = var**0.5
gauss = np.array(self.numpyImg.shape)
gauss = np.random.normal(mean,sigma,(row,col,ch))
gauss = gauss.reshape(row,col,ch)
noisy = self.numpyImg + gauss
self.noisyImage = noisy.astype('uint8')
def show(self):
logging.debug("Konwersja zaszlumionego obrazu do typu Image")
image = Image.fromarray(self.noisyImage)
logging.debug("Wyswietlenie obrazu w channelu")
image.show()
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}