Example #1
0
def conv():
    a = np.random.rand(*(100, 100, 400))
    b = np.random.rand(*(10, 10, 10))

    conv1 = convolveim(a, b, mode='constant')
    # conv2 = convolvesig(a,b, mode = 'same')
    return conv1  # FLOPS / (t2-t1)
Example #2
0
File: aws.py Project: depsched/sim
    def compute_flops(loopcount):
        a = np.random.rand(*(100, 100, 100))
        b = np.random.rand(*(10, 10, 10))

        conv1 = convolveim(a, b, mode='constant')
        # conv2 = convolvesig(a,b, mode = 'same')
        return conv1  # FLOPS / (t2-t1)
Example #3
0
    def convolve_imag(self, image):
        """
        Returns a image convolved with the imaginary component of the kernel
        """
        start_time = time.time()
        conv = convolveim(image, np.imag(self.kernel), mode='wrap')
        self.imag_time += time.time() - start_time
        self.imag_cont += 1

        return conv
Example #4
0
    def convolve_real(self, image):
        """
        Returns a image convolved with the real component of the kernel
        """
        start_time = time.time()
        conv = convolveim(image, np.real(self.kernel), mode='wrap')
        self.real_time += time.time() - start_time
        self.real_cont += 1

        return conv
Example #5
0
def conv_oa(ias, weights, shift):
    oc = weights.shape[0]
    ic = ias.shape[0]
    ia_size = ias.shape[1]
    pad_size = (weights.shape[2] - 1)/2
    #ia_pad = numpy.zeros((ic, ia_size+pad_size*2, ia_size+pad_size*2), dtype=numpy.int) 
    #ia_pad[:,pad_size:ia_size+pad_size,pad_size:ia_size+pad_size] = ias
    oa_raw = numpy.zeros((oc, ia_size, ia_size), dtype=numpy.int) 
    for oc_cnt in range (0, oc):
        for ic_cnt in range (0, ic):
            oa_raw[oc_cnt] = numpy.add(oa_raw[oc_cnt], convolveim(ias[ic_cnt], weights[oc_cnt][ic_cnt], mode='constant'))

    oa = numpy.right_shift(oa_raw, shift)
    return oa, oa_raw
Example #6
0
    def Conv3d(self):
        if self.origImg[0].shape[0] > 10:
            paramText = self.conv3dLineEdit.text()
            parameterList = paramText.split(',')
            if len(parameterList) != 5:
                QMessageBox.warning(self, 'warning',
                                    'please input right parameter')
                return

            self.xBlurSize = int(parameterList[0])
            self.yBlurSize = int(parameterList[1])
            self.zBlurSize = int(parameterList[2])
            self.sigma1 = float(parameterList[3])
            self.sigma2 = float(parameterList[4])
            center = [
                np.round(self.zBlurSize / 2),
                np.round(self.yBlurSize / 2),
                np.round(self.xBlurSize / 2)
            ]
            psf = np.zeros((self.zBlurSize, self.yBlurSize, self.xBlurSize))
            for i in range(self.xBlurSize):
                for j in range(self.yBlurSize):
                    for k in range(self.zBlurSize):
                        psf[k, j,
                            i] = np.exp(-((i - center[2])**2 +
                                          (j - center[1])**2) / self.sigma1 -
                                        ((k - center[0])**2) / self.sigma2)
            psf /= np.sum(psf)
            #img = self.origImg[0].astype(np.float)
            self.origImg[1] = convolveim(self.origImg[0],
                                         psf)  #  np.ones((11,1,1))/11
            #self.origImg[1] = self.origImg[1].astype(np.uint8)
            #psfImg = psf.copy()
            #psfImg /= np.max(psfImg)
            #psfImg *= 255.
            #psfImg = np.uint8(psfImg)
            self._RenderImage(self.origImg[1], 1)
        else:
            pass
Example #7
0
 def convolve_imag(self, image):
     """
     Returns a image convolved with the imaginary component of the kernel
     """
     return convolveim(image, np.imag(self.kernel), mode='wrap')
Example #8
0
 def convolve_real(self, image):
     """
     Returns a image convolved with the real component of the kernel
     """
     return convolveim(image, np.real(self.kernel), mode='wrap')